Skip to content

Overload: Timeouts, Backpressure, Load Shedding, and Rate Limiting

11 min reading

Bound useful work and retry amplification while preserving operation semantics.

Page details

Design for failure · Lesson 12

Published · Sources · 11 min reading · Last edited:

Know first: Numbers Every Engineer Should Know; Reading Architecture Diagrams.

Editorial correction:

Earlier design notes used unsupported universal performance or reliability claims. This revision explains conditional mechanisms and explicitly hypothetical examples; no author-run benchmark or production incident is asserted.

More
20px

Northwind: Overload control: deadlines, admission, and recovery

Outcome. After this lesson, you can protect checkout capacity before the queue fills.

Hypothetical scenario. At Northwind, A slow provider leaves checkout workers occupied until new work queues.

In short. Reject excess work within a bounded deadline. Limit queue time as well as worker concurrency.

Waiting work becomes the outage

Hypothetical scenario. A catalogue depends on an inventory service. When inventory slows, callers keep their connections open and retry. The catalogue's worker pool fills with waiting requests, so even unrelated description reads stop completing. A slow dependency has become a wider failure through shared resources.

Reliability controls manage work under uncertainty and scarcity. A timeout bounds a wait; a circuit breaker changes admission after observed failures; a bulkhead isolates a resource pool; a rate limit bounds admitted arrivals over a defined interval. These mechanisms interact, but none makes a dependency correct or increases its processing capacity.

Use the operation identity and measurement boundaries from the preceding lessons. A control policy must distinguish useful logical tasks from repeated attempts and know which scarce resource it is protecting. Otherwise a successful retry policy can consume the capacity needed for recovery.

A longer timeout can increase the pressure

Extending every timeout gives a slow dependency more time but also retains caller resources longer. With fixed concurrency, that can reduce the rate at which new work is admitted. An unbounded queue moves the symptom into memory and waiting time rather than removing excess demand.

Retries are additional work. If multiple layers retry independently, a single user action can produce many downstream attempts. Backoff spreads attempts over time; it does not make their resource demand disappear. Randomized delay reduces synchronized arrivals under a chosen policy but does not establish an acceptable total retry budget.

Rejecting work also has a cost. Authentication, routing and constructing a response can consume significant resources. Protect the service early enough to avoid spending its entire budget explaining that it cannot accept more work.

Put a budget at each resource boundary

An end-to-end deadline limits the useful lifetime of a task. Each stage should spend from the remaining budget, accounting for queueing, connection setup, execution and response handling. Giving every stage the original full timeout can allow the total journey to exceed the caller's useful wait.

Admission and isolation protect useful workIncoming tasks pass a bounded admission decision. Inventory and description operations use separate bounded pools. A breaker can reject inventory attempts without filling the description pool, but shared dependencies still need protection.Task deadlineattempt budgetBounded admissionand waitingInventory poolbreaker + limitDescription poolseparate limitIsolation is only as strong as the remaining shared resources.

A breaker usually permits calls, rejects them while open, and later allows limited recovery probes. The exact transition conditions are policy decisions. It protects callers from repeatedly waiting on a known unhealthy path; it does not prove that the next accepted call will succeed.

Bulkheads reserve separate concurrency or other resources for work classes. If those classes still share one saturated database, thread pool or network link, isolation is incomplete. Name the resource being isolated and the shared dependencies that remain.

Protect checkout capacity before the queue fills

When Northwind's card provider slows down, occupied application work can grow even if new customer demand stays unchanged. A timeout limits how long the caller waits, while admission controls decide whether to start more work. A circuit breaker can limit calls after selected failures; a bulkhead partitions scarce capacity so one dependency does not consume every worker. These controls solve different problems and need separate measurements.

Use a hypothetical steady arrival rate of two hundred requests per second. At an average occupied duration of 0.1 seconds, Little's Law gives 200 × 0.1 = 20 occupied requests on average under stable accounting. If duration rises to one second at the same arrival rate, the corresponding figure becomes 200. A fifty-slot worker budget cannot sustain that changed state without queue growth, rejection, reduced demand or more effective service capacity.

Queue waiting also spends the caller's deadline. With an illustrative total deadline of eight hundred milliseconds, five hundred already spent in a queue leaves only three hundred for execution and response. Beginning work that cannot produce a useful result within that remaining contract can consume capacity while creating another abandoned request. Bound waiting explicitly and distinguish admission rejection from an operation whose remote outcome is uncertain.

Retries create aggregate demand across clients. If a thousand callers each make one initial attempt and two extra attempts, the attempt count is 1,000 × 3 = 3,000 even though there are only one thousand logical operations. Backoff spreads timing, but a shared attempt budget and useful rejection path are still needed. Protecting the service means preserving enough capacity for work that can finish, not maintaining an indefinitely growing waiting room.

Derive attempts, waiting and burst size

Hypothetical scenario. Choose 100 logical tasks per second. Three nested layers each allow at most three attempts, including the initial attempt. If every call reaches the next layer and every layer exhausts its allowance, one task can trigger 3 × 3 × 3 = 27 calls to the deepest dependency, producing 100 × 27 = 2,700 deepest attempts per second.

This is a worst-case construction under those assumptions, not a prediction that every retry system reaches that rate. A shared task-level budget and deliberate ownership of retries can prevent independent multiplication. Idempotency protects effects; it does not erase those attempted calls.

For waiting resources, choose 100 arrivals per second and a mean occupied duration of two seconds in stable flow. Mean occupancy is 100 × 2 = 200. If duration rises to five seconds at the same stable arrival rate, required mean occupancy becomes 100 × 5 = 500. A pool capped at 200 cannot simply sustain that new workload without queueing, rejection or another change.

A token-bucket example chooses a capacity of 20 admission tokens and a refill of five tokens per second. Starting full, the nominal upper bound over a four-second interval is the initial 20 plus 5 × 4 = 20 refilled tokens, totaling 40 admissions, subject to event timing and available demand. This bounds admitted count under the stated algorithm, not concurrent work or total CPU usage.

Finally, choose a 1,000 ms task deadline. Queueing consumes 150 ms and an initial attempt consumes 600 ms, leaving 1,000 − 150 − 600 = 250 ms. A proposed 300 ms backoff already exceeds that remaining budget, before another attempt starts. Retrying cannot meet the original deadline under this plan.

In the wild: Protect checkout capacity before the queue fills

The primary reference establishes this concrete distinction: overload controls need actual resource and rejection-cost accounting.

A fallback is another contract

A stale description may be an acceptable degraded response; a fabricated inventory confirmation is not. Define which operations can return less information, older information or an explicit unavailable result. A fallback that silently changes a correctness guarantee can be worse than a visible rejection.

Reserve recovery capacity. A service might shed optional enrichment while preserving status checks and reconciliation. Priorities need authorization and fairness rules; if every caller can mark its work critical, the classification provides little protection.

The Google SRE chapters on handling overload and cascading failures explain resource-aware admission and amplification. Their historical workloads are not universal settings for this service. Choose thresholds from the service's observed behavior and explicit objectives.

Every caller probes at once

Hypothetical scenario. All client processes open their inventory breakers during an outage. They use the same fixed recovery delay. When it expires, every process sends a burst of probes and queued retries. The recovering dependency becomes overloaded before normal traffic can stabilize.

Limit recovery probes, spread their timing and bound retained work. A per-process limit still multiplies across all processes, so estimate the aggregate. Queued tasks may have expired while the breaker was open; discard or reconcile them according to their task contract instead of automatically releasing the backlog.

Observe successful useful completions, resource occupancy and queue age while increasing traffic cautiously. A brief successful probe does not establish restored capacity at the full workload. Recovery is a controlled transition, not simply a switch from rejecting everything to admitting everything.

Controls do not substitute for semantics

“Timeout means the server stopped.” It establishes a local waiting decision unless cancellation is separately confirmed. An effect can still complete and require reconciliation.

“A rate limit bounds concurrency.” Arrival limits and occupied work are different dimensions. Long tasks can exhaust concurrency even below the request-rate threshold.

“A separate worker pool guarantees isolation.” It protects that pool boundary. Shared storage, memory or network constraints can still connect the failure paths.

Choose controls from the scarce resource

Use deadlines for useful waiting, concurrency limits for occupied resources, bounded queues for limited bursts, and scoped rate policies for admission and fairness. Use breakers where repeated dependency failures waste caller resources. Specify how clients handle rejection without creating another uncontrolled retry loop.

Avoid adding several interacting adaptive policies without understanding their combined feedback. Each can react to the others' rejections or delays. Begin with clear budgets and measurements, then evaluate low-traffic, cold-start, partial-failure and recovery conditions.

The coordination module next examines agreement and transactions. These reliability controls can preserve resources while coordination is unavailable, but they cannot decide which conflicting state transition is correct. The operation's safety rule still needs an appropriate authority and transaction boundary.

Limits of this model

Little's Law describes stable average accounting and does not predict every burst. The useful control threshold depends on resource cost, caller deadlines and rejection behavior. A rejected admission and an uncertain remote effect require different responses even when both surface as a failed request.

Check yourself: protect useful work

The client timed out and immediately retries an additive action with a new operation identifier. Which risks remain?

The original action may still complete, so the new identity can create another effect. The retry also adds resource demand. Preserve the logical identity, reconcile uncertain state and respect a task-level deadline and attempt budget.

Request rate is unchanged, but mean occupied duration doubles. Can the same concurrency budget be assumed sufficient?

No. Under stable accounting, required mean occupied work doubles. Inspect the actual bottleneck and choose admission, bounded waiting or capacity changes rather than assuming a rate limit covers concurrency.

Every process allows one recovery probe. Is that one probe for the dependency?

No. Aggregate probes across processes and other callers. Limit their combined pressure and spread timing while observing recovery under useful work.

Northwind decision log

Reject excess work within a bounded deadline.
Limit queue time as well as worker concurrency.
Spread retries within a shared attempt budget.

Go deeper: Protect checkout capacity before the queue fills

Related blog: Bounding retries across provider failures.