Backpressure
How Nova bounds the memory and work on every node, and what clients see when a limit is reached.
Backpressure keeps a node working when clients send faster than storage can take. Every buffer and queue on a node has a limit. When one fills, the step before it waits, or new work is refused with a retryable error. Either way the node keeps its memory within bounds, so a storage outage or a burst of clients slows Nova down instead of crashing it.
The parts
| Part | What it does |
|---|---|
| Session window | The bytes a producer session may have sent and not yet had acknowledged: 48 MiB on Standard, 8 MiB on Express, and 1,024 batches |
| Pool | A node's accepted batches waiting to be written, 256 MiB per class |
| Slot window | The flights of one class uploading at once, 128 |
| Backlog | Acknowledged flights not yet indexed: at most 1,024 flights and 4 GiB per class |
| Memory plan | The node's division of its memory into budget lines: write buffers, caches, and a count of sessions, subscriptions, and one-shot calls |
| Heap watermark | A check of the node's live heap against the plan, which refuses new work and ends sessions when memory runs short |
Wait or refuse
Most limits make work wait. Work already accepted stays queued until there is room. Appends wait for the pool and the backlog. The node's ingress budget is the memory it allows for requests being read and decoded. An HTTP request waits for room in it before its body is read, up to the request's deadline, or 30 seconds without one. Auditor jobs wait for their request budgets. A client sees slower calls, or gRPC flow control pausing its sends. Nova measures the waits on the write path and logs any that lasts over 5 seconds.
Other limits refuse new work at once, with ResourceExhausted. This is called shedding. It applies to producer sessions, subscriptions, and one-shot calls past the memory plan's counts, and to new calls while the heap is past its watermark. Sessions already open keep working.
Nova waits where the work is already in memory and the wait is short. It refuses where accepting more would only add memory that has to wait too. A client can always retry a refusal safely, because nothing was accepted.
When storage slows
- Uploads take longer, and the 128 slots of the class's window fill.
- The flusher can start no new flight, so the pool fills. At 256 MiB, new batches wait.
- Producers stop getting acknowledgements. Each session stops sending when its window of unacknowledged bytes is full.
- If the metadata store is slow instead, uploads finish, but absorb falls behind. When the backlog reaches 1,024 flights or 4 GiB, new slots wait, then the pool fills as above.
Nova records the cause of each stall: absorb falling behind, a slow metadata store, or a ledger change. A slot that cannot reach its copy quorum within 30 seconds stops its ledger, and the node starts a new one. A node changes ledgers at most 3 times in a row, then once every 200 seconds. Past that, appends wait for the next allowed change. See How a write becomes durable.
The limits also bound the cost of a failure. The backlog limit caps how much a successor must index after a crash, and how long only the leader knows where the newest records are.
The memory plan
A node sizes its limits from the memory it has. Its ceiling is three quarters of the container's memory limit by default. The plan divides it into budget lines: the pools, the tail and footer caches, the ingress budget for HTTP bodies, and a count of open sessions, subscriptions, and waiting one-shot calls. With Go's default garbage collector setting, the plan holds back half of the ceiling as room for garbage collection.
The plan counts each producer session at 28 KiB, what an idle one holds. Sessions get half of the memory the other lines leave: with the default settings, about 19,500 on an 8 GiB node and 74,000 on 16 GiB. A subscription counts 28 KiB, up to 16,384 a node. A one-shot append or queue send waiting for its answer counts 24 KiB plus its batch, up to 8,192 a node. Past a count, new calls are refused.
The pool charges a batch as soon as it is decoded: its bytes plus the measured cost of each record and batch. The charge moves to the tail cache when the batch is acknowledged, so every byte is counted once. A batch larger than the whole pool is charged at most the pool, so it still gets in instead of waiting forever.
The node's retained memory also counts toward saturation. Close to the ceiling, the node takes no new leaders and hands streams to other nodes. See Leadership and failover.
Why an outage cannot exhaust a node's memory
During a long storage outage, nothing is acknowledged, and every limit fills. The pool and the backlog stop at their limits. But a session whose next batch waits still holds that batch decoded, and its transport buffers up to 64 KiB more. Across tens of thousands of sessions, that is more than the counts allow for. The heap watermark covers the difference:
| The node's live heap | What the node does |
|---|---|
| Above the high mark: the plan's full load plus 5%, or 85% of the most the node can hold if that is lower | Refuses new calls with ResourceExhausted, and stops reading from open sessions, which then wait in flow control |
| Above the hard line: halfway from the high mark to the most the node can hold | Ends the sessions holding the most memory, those with a batch waiting first. Each ends with Unavailable "busy, retry" and a hinted wait. |
| Back below the low mark: the plan's full load minus 5%, or 80% of the most the node can hold | Takes new calls again. For 30 seconds, session opens and resumed reads get only the room left under the hard line, so returning clients do not overshoot again. |
A session ended this way loses no acknowledged record. Its producer resends the batches that got no acknowledgement, so a plain append may be stored twice. If the store is stalled, the ended session waits half a second for its batches' acknowledgements, then closes without them. When the stall and recovery last longer than the SDK's 30-second retry budget, the producer fails with an unknown outcome for those appends. Calls on the admin plane are never refused, so an operator can still inspect the node.
Reads apply backpressure by reading slower
A read returns at most 8,192 records and 8 MiB per response, and fetches from storage for at most 8 refs at a time. A subscription has no queue of its own on the node. A slow consumer reads more slowly. It falls behind the tail cache, then reads from storage, and it cannot make the cache keep records for it. Slow readers cost storage requests, and hold no growing buffer on the node.
Go deeper
WAL, slots and ledgers
The slot window, the backlog, and what halts a ledger
Node limits and budgets
Every limit with its setting and default
Sizing
How to size nodes, and the memory ceiling
Back to the concepts: Appends.