Node bounds
Queues

Node bounds

The embedder's Dispatch configuration that bounds a node's queue memory, sessions, and claims, with the fixed values beside it.

Everything a node holds or serves as a queue dispatcher has a bound, so a flooded queue or a crowd of workers cannot take the node's memory. The bounds are the fields of daemon.DispatchConfig, set as daemon.Config.Dispatch by the program that builds the node. novad has no flags for them and the Kubernetes resource has no fields, so a stock deployment runs with the defaults.

Where it lives

FileWhat it holds
internal/daemon/dispatchconfig.goDispatchConfig, its validation, and how it becomes the seats' options
internal/queue/seat.go, seats.go, fetch.go, share.go, pages.goThe defaults, and what a seat does at each bound
internal/transport/grpc/queue/claim.goThe one-shot claim bounds

Node bounds

A zero value takes the default, and a negative one is refused at start. The two shares must be above zero and below one.

FieldDefaultWhat it boundsAt the bound
WindowBytes8 MiBMemory one seat holds for its range, counted as heap: an entry per message read and not settled, and the records held for some of themThe seat reads no further until messages are settled
WindowBudgetBytes512 MiBThe same across all the node's seats, shared as the window budget describes. At least WindowBytes, and it must leave each of MaxSeats seats 32 KiB after the fetch pool.A seat held to its share reads no further. Seats above their share give back read-ahead, then ready entries.
ReadAheadBytes1 MiBThe most records one seat holds ahead of their deal. A seat aims at half a second of what it deals, at least 64 KiB, and at most half its limit.The seat's read waits. Records it could not keep are fetched just before their deal.
HoldFull10 sHow long a seat's read must stand held behind its range before its window counts as full, for noisy-key isolation and the leftover class. A worker dealing nothing meanwhile makes the read read on to its window.None
ClaimsPerSecond0, no boundThe dispatch budget: claims a second across the node's seatsSeats wait for the budget
SeatFloor1Claims a second each seat gets whatever the others take. Used only with a budget, and never above it.None
LeftoverShare0.1The share of a queue's claims on the node that its leftover ranges get while its quiet ranges have workNone
MaxWorkSessions512Work sessions open on the nodeThe next open is refused RESOURCE_EXHAUSTED with QueueLimit{max_work_sessions}
MaxCredits1,024Unspent credit in one work session, counting deliveries not yet writtenThe grant is refused with max_credits, and the session ends
MaxClaimWaits128One-shot claims waiting on the nodeThe next claim is refused RESOURCE_EXHAUSTED with max_claim_waits
MaxClaimBatch256Messages one one-shot claim returns. At most MaxCredits.A larger max is answered as this
MaxClaimWait30 sHow long a one-shot claim waitsA longer wait is answered as this
MaxReplayLimit1,000Dead letters one replay sendsA larger limit is answered as this
DueScanLimit256Ripe due keys one read of a range's due keys takesThe fire reads the next page at once
NoisyShare0.5The share of a full window one routing hash must exceed to be isolatedNone
MaxIsolatedRanges16One-hash ranges a queue may hold openA further noisy key stays in its range
IsolationRetry30 sHow long a seat waits before it asks again for an isolation not yet madeNone
MetricQueues32, at most 1,024Queues the node names in each queue age gaugeThe rest share one series, address="other"
SeatIdle60 sHow long a seat stays open after its last worker leavesThe seat saves, releases its range, and closes, unless it holds claims, writes on their way, unarmed delays, records being sent, or keyed ids in their window
MaxSeats8,192Seats open on the nodeA range that needs a seat waits, and the seat idle longest that holds nothing open closes for it
MaxDealtRanges1,048,576Ranges the node deals for the queues its workers reachAn open deals what fits, and the node reads that queue's map again at each pass until all fit

A waiting one-shot claim also holds a work session on the node that received it and on every node it asks, and counts against MaxWorkSessions on each.

The dispatcher's pass interval, 5 seconds, is daemon.Config.DispatchPassInterval, also with no flag.

Fixed values

These are package constants or seat options a host cannot set through DispatchConfig:

WhatValue
Deficit round robin quantum, per key per round64 KiB
Progress saveEvery 250 ms, or after 1,024 settled positions
Records one fetch read asks for256 records or 1 MiB
Gap a fetch read spans to join two wanted records256 KiB
Fetches out per seat, and reads per fetch1 fetch of up to 8 reads
Fetch reads in flight per node64. The next waits.
Time a fetch read has to answer3 seconds
Record reads a node serves at once, for its own seats and for peers64. The next waits, counted by nova.read.slot_waits.
The fetch pool, kept from WindowBudgetBytes64 reads × 1 MiB, at most an eighth of the budget
A batch from a seat's readAbout 256 KiB
A cold page from the read path8 MiB
Read-ahead floor, lead, and rate half-life64 KiB, 500 ms, 1 s
Give-back rest, and the lull before borrowing again1 s, 10 s
Remembered idempotent ids per node, memory dedup1,048,576
Idempotent send window5 minutes
Dispatch shards, and news groups1,024, and 16
Maps and index rows read at once on a gained shard16
Release grace, before a seat takes over an unreleased range2 seconds
A key-ordered child range's check of its parentsEvery second
A failed seat's pause before its range opens again5 seconds
One-shot claim's look for a dispatcher, while it waitsEvery 250 ms

The cold-page reservation

When a seat's read falls behind the leader's memory, it reads from object storage in cold pages of 8 MiB. A seat reserves room for a page in the window budget, beside its window, before the read fetches it. Reads that cannot get room wait first come, first served.

  • While the node's seats use less than three quarters of the shared budget, a page is reserved whole.
  • Past three quarters, a page is reserved at the seat's read-ahead target, so cold readers cannot crowd out the seats that are dealing. The node logs queue: the star's window budget is three quarters used; cold pages are reserved at their seats' read-ahead targets and counts nova.queue.cold_pages.sized.
  • A seat whose worker has dealt nothing from its page for HoldFull, while the node is past three quarters, lets the page go, counted by nova.queue.cold_pages.let_go. A seat with no worker lets its page go at its next save.

The dispatch budget

ClaimsPerSecond caps the claims a second a node deals across all its queues, which protects the node and its metadata store when one queue floods. It is off by default. Every seat also has a floor of its own, SeatFloor. A claim is allowed when either the floor or the shared budget affords it, and it is charged to both. So a claim only the floor afforded can take the shared budget below zero, by at most one second's claims.

The budgets refill from the clock when a claim asks, not on a timer. One timer runs only while a seat is waiting. One second of unused budget is kept, so an idle node can deal one second's claims in a burst. If the floors add up to more than the budget, the floors win. A node holding seats back logs queue: the dispatch budget held seats back and counts nova.queue.budget.held, once each time a seat starts waiting.

Bounds and signals

  • Memory: nova.queue.window.held by part (entries, read-ahead, sending, reserved, prefetch), nova.queue.window.share, nova.queue.read_ahead.target, nova.queue.window.given_back by part.
  • Seats: nova.queue.seats by state, nova.queue.seats.waited, nova.queue.ranges.dealt, nova.queue.queues.attended.
  • Log queue: seat's window is full; its read waits for messages to be settled
  • Log queue: seats at the bound; ranges wait for a seat to close
  • Log queue: the dealt ranges of attended queues are at their bound; ranges are left undealt
  • Log queue: work sessions refused at the bound; no more is said until one closes

Tests

  • Validation: TestDispatchBoundsAreValidated, TestDispatchShareFloorIsValidated, and TestDispatchBoundsReachTheSeats in internal/daemon/dispatchconfig_test.go.
  • Cold pages: TestAColdPageIsSizedToItsSeatsTargetPastThreeQuarters, TestAStuckSeatLetsItsColdPageGo, and TestAReadWaitsForRoomForItsPageFirstComeFirstServed in internal/queue/coldstar_test.go.
  • The dispatch budget: TestAFloodedQueueDoesNotStarveAQuietOne and TestASeatHeldByTheBudgetWaitsOnOneTimer in budget_test.go.
  • Seats: the TestAtMaxSeats tests in lazy_test.go; TestTheDealtRangesAreBounded in attend_test.go.

Go deeper

Why queues hold so little: Queues on streams.

On this page