SysDesignAtlas

Backpressure, Load Shedding & Circuit Breakers

How systems collapse under overload, why accepting every request is the wrong instinct, and the three mechanisms that keep degradation graceful.

HLDMedium10 min readbackpressureload-sheddingcircuit-breakerresilience
Confidence

#The counterintuitive premise

The instinct under overload is to accept every request and try your best. That instinct destroys systems.

A system pushed past the point where it can keep up doesn't serve everyone slowly — it serves no one. Queues grow, responses take longer than clients are willing to wait, those clients give up and retry, the load goes up again, and useful throughput falls to zero while every machine sits at 100% busy. Work is being done; none of it reaches anybody. See the saturation curve in Latency & Throughput.

The correct behaviour under overload is to do less work, deliberately. Rejecting 20% of requests quickly so the other 80% succeed at normal latency is strictly better than accepting 100% and completing none of them within their deadline.

The one-line version — "under overload, shed rather than queue" — compresses the whole argument, and it is the right default.

#Backpressure

Backpressure is the ability of a slow consumer to tell a fast producer to slow down. It's a property of the whole pipeline, not a component you add.

   WITHOUT backpressure
   producer 10K/s ──► [ unbounded queue ] ──► consumer 1K/s
                       grows 9K/s → OOM, or latency
                       climbs until every item is stale

   WITH backpressure
   producer ──► [ bounded queue ] ──► consumer 1K/s
                  full → producer BLOCKS or is REJECTED
                  → the pressure propagates upstream

The key design rule: every queue must be bounded. An unbounded queue doesn't remove a bottleneck; it hides one, converting a throughput problem into a memory problem plus unbounded latency. Work processed hours late is often worse than work rejected immediately — a notification about a meeting that already ended has negative value.

Mechanisms:

  • Bounded buffers that block or reject on full.
  • TCP flow control — the original backpressure. The receiver keeps telling the sender how much free buffer space it has left (the receive window), and the sender may not send more than that. If your code stops reading from a socket, the buffer fills, the window drops to zero, and the sender stalls. Free, and often overlooked.
  • Pull instead of push — the consumer asks for N items and the producer never sends more than were asked for. Flipping the direction of the request makes backpressure structural rather than something you bolt on.
  • Credit-based flow control — the consumer hands out a budget of "you may send me 50 more"; each message spends one. Same idea as pull, common in messaging systems.
  • Blocking calls — sometimes the simplest correct answer. A blocked thread is backpressure, propagating naturally up the call chain.

Where backpressure fails: at the boundary with the outside world. You cannot make users slow down. At the edge, backpressure becomes load shedding — the only remaining option is to say no.

#Load shedding

Deliberately dropping work you can't complete in time.

Shed early and cheaply. A request rejected at the edge costs nothing. One rejected after a database round trip has already consumed a connection, a thread, memory, and downstream capacity — the most expensive way to fail.

Shed by priority, not at random. This is where the design gets interesting, and where it is tempting to stop too early.

   Priority classes, shed from the bottom up:

   CRITICAL   checkout, payment, login       never shed
   HIGH       core reads, add-to-cart        shed at 95% load
   MEDIUM     recommendations, related items shed at 85%
   LOW        analytics, prefetch, batch     shed at 70%

The user completing a purchase succeeds while the recommendation carousel silently disappears. That's graceful degradation implemented as a load policy — and it requires product knowledge, which is exactly why it reads as a senior answer.

Other ways to choose what to shed:

  • By cost — reject expensive queries (a full-text search across a year of data) before cheap ones (fetch one record by ID).
  • Oldest first — shed the requests that have been queued longest. They're closest to their deadline, and their users may already have given up. This means serving the queue newest-first — "LIFO (last in, first out) under overload" — which is counterintuitive and correct.
  • Already expired — drop requests whose deadline has already passed without doing any work at all.

Adaptive concurrency limits are the modern approach. Rather than a static "max 500 concurrent requests", measure latency continuously and adjust the limit automatically. The target is the throughput knee — the load level where adding more concurrent requests stops increasing throughput and only increases latency. If latency starts climbing, lower the limit; if latency is flat, try raising it. This is essentially TCP congestion control applied to service calls (Netflix's concurrency-limits and Gradient algorithms work this way). Naming this is a nice depth signal, because a static limit that's right today will be wrong after the next deploy or hardware change.

#Circuit breakers

Protect yourself from a failing dependency. Without one, calls to a dead service consume your threads and connections while you wait for timeouts — the dependency's outage becomes yours.

        ┌────────────┐  failure rate > threshold   ┌──────────┐
        │   CLOSED   │ ──────────────────────────► │   OPEN   │
        │ calls pass │                             │ fail fast│
        └────────────┘ ◄──────────────────────────┐│ no calls │
              ▲          probe succeeded          │└──────────┘
              │                                   │      │ after cooldown
              │        ┌────────────────┐         │      ▼
              └────────│   HALF-OPEN    │◄────────┘
                       │ allow a trickle│
                       └────────────────┘
                              │ probe failed → back to OPEN
  • Closed — normal. Track the failure rate over a rolling window.
  • Open — fail immediately without calling. This is the point: you stop wasting resources and you stop hammering a struggling dependency, giving it room to recover.
  • Half-open — after a cooldown, allow a few probes. Success closes the breaker; failure reopens it.

Details that matter:

  • Trip on rate, not count. "50% of the last 100 calls failed" adapts to traffic; "20 failures" trips instantly at high volume and never at low volume.
  • Require a minimum volume. 2 failures out of 3 calls is noise, not a signal.
  • Breakers need fallbacks. An open breaker must produce something — cached data, a default, a degraded response. A breaker that just returns errors faster has only changed your failure's latency.
  • Scope them per dependency, and often per endpoint. One slow endpoint on a service shouldn't take out calls to its healthy ones.
  • Pair with bulkheads — separate connection/thread pools per dependency. If the payments service hangs, it can tie up at most its own 20 threads; calls to search and profile still have theirs. That contains the damage even before the breaker trips.

#Retries: the amplifier

Retries interact badly with overload and deserve explicit attention, because they are the most common way a small problem becomes an outage.

  • Exponential backoff with full jitter. Exponential backoff doubles the wait after each failure (1 s, 2 s, 4 s…). Full jitter means waiting a random time between zero and that value instead of exactly that value. Without jitter, clients that failed together retry together, producing synchronized load waves against an already-struggling service.
  • Retry budgets. Cap retries as a share of total traffic — say, no more than 10% of the requests you send may be retries. When everything is failing, that budget is exhausted immediately and retries simply stop, instead of doubling the load on a service that's already drowning. Far more robust than per-request limits, which still allow fleet-wide amplification.
  • Retry at one layer only. Retries multiply when stacked: each of the client's 3 attempts makes the gateway try 3 times, and each of those makes the service try 3 times. Client 3× → gateway 3× → service 3× = 27 database queries per user action.
  • Never retry on 4xx. A bad request stays bad. Retry only on timeouts, 5xx, and connection failures.
  • Don't retry when the circuit is open. The breaker already knows.

Get these wrong and an overload can outlive its cause: retries, cold caches and recovery backlogs keep the system pinned above capacity after the trigger has passed. That's a metastable failure, and designing so the system climbs back out on its own is the subject of that page.

#Putting it together

The layered defense, and reciting this structure answers most "what happens under load?" questions completely:

Edge rate limit · shed low-priority · absorb volumetric attacks Gateway adaptive concurrency · deadline propagation · priority classes Service bounded queues · bulkheads · circuit breakers · fail fast Data connection pool limits · query timeouts · read replicas
Layered defence — shed early, where a rejection costs nothing.

Plus the operational side: run at 60–70% utilization so a node loss doesn't push survivors past the knee, and load test past the breaking point so you know where the knee is and what failure looks like — rather than discovering both during an incident.

#Check yourself

Why does accepting every request under overload destroy a system?Show answer
Queues grow, responses outlast client patience, clients retry and add load, and useful throughput falls to zero while every machine is 100% busy. Shedding 20% so 80% succeed is strictly better.
What is backpressure, and what's its key design rule?Show answer
A slow consumer telling a fast producer to slow down. Rule: bound every queue — an unbounded one hides the bottleneck, turning it into memory exhaustion and unbounded latency.
Name three mechanisms that create backpressure.Show answer
Bounded buffers that block or reject; TCP flow control; pull-based consumption (the consumer asks for N); credit-based flow control; and blocking calls that propagate upstream.
Why shed load by priority, and how?Show answer
So the most valuable work survives: never shed checkout or login, shed recommendations and analytics first. Graceful degradation becomes a load policy — which needs product knowledge.
Why might you serve the newest queued requests first under overload?Show answer
The oldest are closest to their deadline and least likely to still be wanted. Requests already past their deadline should be dropped without doing any work.
What is an adaptive concurrency limit?Show answer
Instead of a fixed cap, measure latency continuously and adjust the concurrency limit to stay at the throughput knee — TCP congestion control applied to service calls.
Describe the circuit breaker's three states.Show answer
Closed: calls pass while the failure rate is tracked. Open: fail immediately without calling, protecting your threads and giving the dependency room. Half-open: after a cooldown, let a few probes through to decide whether to close.
Name three circuit-breaker details that matter.Show answer
Trip on failure rate with a minimum volume, not a raw count; always have a fallback (cache, default, degraded response); scope breakers per dependency or endpoint; pair them with bulkheads.

#What to carry forward

  • Under overload, shed rather than queue — doing less on purpose keeps the rest fast.
  • Bound every queue; propagate pressure upstream with blocking, pull or credits.
  • Shed early, by priority, newest-first, and drop requests already past their deadline.
  • Circuit breakers stop a failing dependency from taking you down — trip on rate, with fallbacks.
  • Retries amplify overload: jitter, a fleet-wide budget, one layer only, and never on 4xx.
00:00
/ 10m