Course map

Topic 097 / Advanced

Backpressure, load shedding and admission control

Chapter 6.4 · Traffic Control and Workload Shaping

What and why

Rate limiting (→ 96) caps requests per identity, but a system can still be overloaded in aggregate even when every individual client is well within its limit — too many well-behaved clients at once. Backpressure, load shedding, and admission control are three ways a system protects itself once it's already at or past capacity, each acting at a different point: backpressure signals "slow down" upstream via a bounded queue that fills and pushes back; load shedding rejects some incoming work outright, cheaply, to protect the work it keeps; admission control decides, at the front door, how much is allowed in before any of it starts. Builds on: → 96 (rate limiting).

Diagram

request ──► admission control (let it in at all?)
              │ admitted
              ▼
          bounded queue ──full──► backpressure (signal upstream to slow down)
              │
              ▼
          worker pool ──at capacity──► load shedding (reject cheap, low-priority work)

How it works

  1. Admission control acts first, at the boundary: given current load, decide whether to accept a new unit of work at all — e.g., a waiting room that only lets a bounded number of users attempt checkout simultaneously, queueing or rejecting the rest before they ever touch the critical path (the queue-based load leveling pattern of → 110).
  2. Backpressure works through bounded queues: every queue in the system (connection queue, worker queue, a message broker, → 106) has a finite capacity; when it's full, the producer is forced to slow down rather than the queue growing without limit until the system runs out of memory.
  3. Load shedding is a deliberate decision to reject some requests rather than serve all of them badly: reject the cheapest-to-reject and lowest-priority requests first, and reject as early as possible — rejecting after doing most of the work wastes the exact capacity shedding was meant to save.
  4. All three require a priority or cost signal: without one, shedding and admission control degrade to "reject randomly," which protects capacity but not the requests that matter most.
  5. An unbounded queue anywhere in the chain defeats all three — it never signals backpressure and never triggers shedding, it just grows until latency (→ 100) or memory is exhausted.

Practical example

(numbers illustrative). A worker pool processes 100 requests/second sustainably. A spike arrives at 400 requests/second for 10 seconds (4,000 requests total). Without protection, those 4,000 requests sit in an unbounded queue; draining at 100/second, the last one is served 30 seconds after it arrived (40 seconds after the spike began), and the queue has temporarily held (400 − 100) × 10 = 3,000 extra requests in memory. With load shedding capping the queue at 500 and rejecting the rest immediately, accepted requests see a bounded wait of at most 500 ÷ 100 = 5 seconds, and the other 3,500 get an immediate, cheap rejection instead of a wait of up to 30 seconds for nothing.

When to use it

  • Use admission control when the cost of even starting a unit of work is non-trivial — ticket booking, flash sales (→ 110).
  • Use backpressure wherever a producer can outpace a consumer — anywhere a queue exists.
  • Use load shedding once overload is unavoidable and some requests must lose, so the loss is deliberate and prioritized rather than uniform degradation for everyone.
  • Avoid treating these as optional — an unbounded queue with none of them is a crash waiting for enough load to arrive.
  • Failure scenarios: backpressure that blocks a caller indefinitely instead of surfacing a bounded, actionable signal (a timeout the caller can react to, → 152); load shedding with no priority signal, dropping a paying customer's checkout and a crawler's background request with equal probability; admission control sized so conservatively it rejects work the system could actually have handled.
  • Simpler alternative: for a service whose peak load is known and bounded well below capacity, none of this is needed yet — add it when measurement, not fear, shows overload is a real, recurring risk.

Practice

(decision kind — judge scenarios, 20 min).

  1. Given three overloaded scenarios — a checkout flow during a flash sale, a background analytics ingestion pipeline, a public search API under a traffic spike — decide which of admission control, backpressure, and load shedding (possibly more than one) fits each, and what priority signal each would shed by.
  2. Recompute the practical example's numbers with a spike of 300 requests/second for 20 seconds at the same 100 requests/second drain rate, and size a queue cap that keeps wait time under 3 seconds.
  3. Identify one unbounded queue in a system you know (or a hypothetical one) and propose a bound and a shedding rule for it.

Done when your queue-cap sizing for drill 2 produces a wait time you verified by recomputing, not estimated.

Key takeaway

Backpressure, load shedding, and admission control are three points of defense against overload — signal upstream, reject cheaply, or refuse entry — and all three depend on bounding every queue in the system. Done when you can: compute a queue cap that bounds wait time to a target, and assign a priority signal for what gets shed first. Used next in → 98 (graceful shutdown, a deliberate, planned version of removing capacity), → 102 (capacity planning, the headroom these mechanisms buy time for); Project 16 (waiting room / admission control).

References

None — this topic makes no external claims.

Source directory

Search the guide