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
| File | What it holds |
|---|---|
internal/daemon/dispatchconfig.go | DispatchConfig, its validation, and how it becomes the seats' options |
internal/queue/seat.go, seats.go, fetch.go, share.go, pages.go | The defaults, and what a seat does at each bound |
internal/transport/grpc/queue/claim.go | The 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.
| Field | Default | What it bounds | At the bound |
|---|---|---|---|
WindowBytes | 8 MiB | Memory one seat holds for its range, counted as heap: an entry per message read and not settled, and the records held for some of them | The seat reads no further until messages are settled |
WindowBudgetBytes | 512 MiB | The 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. |
ReadAheadBytes | 1 MiB | The 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. |
HoldFull | 10 s | How 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 |
ClaimsPerSecond | 0, no bound | The dispatch budget: claims a second across the node's seats | Seats wait for the budget |
SeatFloor | 1 | Claims a second each seat gets whatever the others take. Used only with a budget, and never above it. | None |
LeftoverShare | 0.1 | The share of a queue's claims on the node that its leftover ranges get while its quiet ranges have work | None |
MaxWorkSessions | 512 | Work sessions open on the node | The next open is refused RESOURCE_EXHAUSTED with QueueLimit{max_work_sessions} |
MaxCredits | 1,024 | Unspent credit in one work session, counting deliveries not yet written | The grant is refused with max_credits, and the session ends |
MaxClaimWaits | 128 | One-shot claims waiting on the node | The next claim is refused RESOURCE_EXHAUSTED with max_claim_waits |
MaxClaimBatch | 256 | Messages one one-shot claim returns. At most MaxCredits. | A larger max is answered as this |
MaxClaimWait | 30 s | How long a one-shot claim waits | A longer wait is answered as this |
MaxReplayLimit | 1,000 | Dead letters one replay sends | A larger limit is answered as this |
DueScanLimit | 256 | Ripe due keys one read of a range's due keys takes | The fire reads the next page at once |
NoisyShare | 0.5 | The share of a full window one routing hash must exceed to be isolated | None |
MaxIsolatedRanges | 16 | One-hash ranges a queue may hold open | A further noisy key stays in its range |
IsolationRetry | 30 s | How long a seat waits before it asks again for an isolation not yet made | None |
MetricQueues | 32, at most 1,024 | Queues the node names in each queue age gauge | The rest share one series, address="other" |
SeatIdle | 60 s | How long a seat stays open after its last worker leaves | The 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 |
MaxSeats | 8,192 | Seats open on the node | A range that needs a seat waits, and the seat idle longest that holds nothing open closes for it |
MaxDealtRanges | 1,048,576 | Ranges the node deals for the queues its workers reach | An 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:
| What | Value |
|---|---|
| Deficit round robin quantum, per key per round | 64 KiB |
| Progress save | Every 250 ms, or after 1,024 settled positions |
| Records one fetch read asks for | 256 records or 1 MiB |
| Gap a fetch read spans to join two wanted records | 256 KiB |
| Fetches out per seat, and reads per fetch | 1 fetch of up to 8 reads |
| Fetch reads in flight per node | 64. The next waits. |
| Time a fetch read has to answer | 3 seconds |
| Record reads a node serves at once, for its own seats and for peers | 64. The next waits, counted by nova.read.slot_waits. |
The fetch pool, kept from WindowBudgetBytes | 64 reads × 1 MiB, at most an eighth of the budget |
| A batch from a seat's read | About 256 KiB |
| A cold page from the read path | 8 MiB |
| Read-ahead floor, lead, and rate half-life | 64 KiB, 500 ms, 1 s |
| Give-back rest, and the lull before borrowing again | 1 s, 10 s |
Remembered idempotent ids per node, memory dedup | 1,048,576 |
| Idempotent send window | 5 minutes |
| Dispatch shards, and news groups | 1,024, and 16 |
| Maps and index rows read at once on a gained shard | 16 |
| Release grace, before a seat takes over an unreleased range | 2 seconds |
| A key-ordered child range's check of its parents | Every second |
| A failed seat's pause before its range opens again | 5 seconds |
| One-shot claim's look for a dispatcher, while it waits | Every 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 targetsand countsnova.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 bynova.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.heldby part (entries, read-ahead, sending, reserved, prefetch),nova.queue.window.share,nova.queue.read_ahead.target,nova.queue.window.given_backby part. - Seats:
nova.queue.seatsby 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, andTestDispatchBoundsReachTheSeatsininternal/daemon/dispatchconfig_test.go. - Cold pages:
TestAColdPageIsSizedToItsSeatsTargetPastThreeQuarters,TestAStuckSeatLetsItsColdPageGo, andTestAReadWaitsForRoomForItsPageFirstComeFirstServedininternal/queue/coldstar_test.go. - The dispatch budget:
TestAFloodedQueueDoesNotStarveAQuietOneandTestASeatHeldByTheBudgetWaitsOnOneTimerinbudget_test.go. - Seats: the
TestAtMaxSeatstests inlazy_test.go;TestTheDealtRangesAreBoundedinattend_test.go.
Go deeper
Dispatch and windows
Seats, the ready window, and how seats share the budget
Read-ahead and fetch
How a seat reads, keeps, and fetches records
Node limits and budgets
The operator's view of every node limit
Why queues hold so little: Queues on streams.