Building at scale · L2Load shedding and graceful degradation

Load shedding and graceful degradation

When more work arrives than you can finish, drop the least important part early and cheaply, so the important part still works.

L2 SeniorBuilding at scale20 min read
Fact-checked by AI against cited sources · Human review pendingLast reviewed 9 Nov 2026 · How we check content
Section 1 of 8

What broke

In 2019, Netflix had an outage. A sizable share of members could not play for a period of time. 1

Netflix lists many things that can overload its systems. A client bug can trigger a retry storm. A backend can be under-scaled. A deploy can be bad, or the network or cloud provider can have problems. Each of these had stopped members from playing at some point. 1

At the time, Netflix had on/off circuit breakers. It had "no progressive way to shed load". 1 So the team built one into Zuul, its API gateway. Each request gets a priority. When things go wrong, low-priority requests are dropped first. 1

In 2020, days after the change went live, a similar problem hit. It had the same potential impact as the 2019 outage. This time Zuul shed traffic until the service was healthy again, "without impacting members' ability to play at all". 1

The problem was just as serious. The difference was that the system chose what to drop.

Section 2 of 8

The idea in simple words

Every server has a limit. When more work arrives than it can finish, some work will fail. You cannot avoid that. You can only choose which work fails, and how.

Without a plan, the server tries to do everything. Then nearly everything fails. With load shedding, the server rejects some requests early and finishes the rest in time.

You already know rate limiting and circuit breakers and bulkheads. The difference matters:

  • A rate limit is usually a fixed quota per client. It stops one client from taking more than its share.
  • Load shedding is the server protecting itself. It looks at its own state, such as CPU or requests in flight, whoever the traffic comes from.

Graceful degradation goes one step further. It cuts the work per request, for example by serving a slightly stale local copy of the data. 3

The key idea. Overload means some work will fail. Decide in advance which work that is. Drop it early, cheaply and on purpose, so the important work still finishes in time.

Section 3 of 8

How it works

What overload does

Step through a server under rising load. Use Next and Back, or the ← and → keys.

A server under rising load: the queue grows, goodput falls to near zero, and priority shedding keeps checkout fastOne server · handles 1,000 requests/s example numbers · clients give up after 1 s 800/sServer✓ no queue · goodput 800/s 1,500/sServerqueue grows by 500 every secondwait grows by 0.5 s every second 1,500/sBusywait > 1 s · callers give up firstthroughput 1,000/s · goodput ≈ 0 With priority shedding · 1,500/sgateprefetch 600/s → 503 at onceServer✓ checkout + pages 900/s · fast At 3,000/s: shed pages too · checkout still fast SeniorPath
  1. Normal day. 800 requests a second arrive. The server can finish 1,000 a second, so there is almost no queue. Every answer arrives in time: goodput is 800 a second.
  2. A spike: 1,500 requests a second arrive. The server still finishes only 1,000. The extra 500 wait in a queue, so each second the wait gets 0.5 seconds longer.
  3. After about 2 seconds, a new request will wait more than 1 second, so its caller will give up first. Soon after, every answer the server finishes is late. The server is 100% busy and finishes 1,000 requests a second, but nobody reads the answers. Goodput is close to zero.
  4. Now the server sheds by priority. A cheap check at the door rejects the 600 prefetch requests at once with 503. Checkout and page loads, 900 a second, fit inside capacity. The queue stays short and answers come back fast.
  5. Load doubles again, to 3,000 a second. The gate raises its bar and sheds most page loads too. Checkout is a small share of traffic, so it still fits, and users can still pay.
Step 1 of 5

The trap is that the server looks busy and healthy. It finishes as many requests as ever. But the client has already timed out, so the work is wasted. Amazon calls the useful part goodput: requests handled without errors and fast enough to use. 2 If median latency equals the client timeout, half the requests time out, so availability is 50%. 2

The Tail latency and queueing lesson showed why queues explode near 100% busy. Load shedding is what you do about it. It lets a server "maintain its goodput". 2

Shed early and cheaply

A rejection must cost much less than real work. Amazon says early rejection "is the cheapest place to drop excess traffic". 2 So check before you parse the body, open a transaction or call another service.

Google warns that rejecting is not always cheap. For a simple memory lookup, rejecting costs almost as much as serving. 3 Shedding has limits, so you still need capacity.

A simple server-side signal is the number of requests in flight. Over a limit, return HTTP 503 to new requests. 4 Google also uses CPU and rejects by criticality as use nears a threshold. 3

Decide what to drop

Not all requests are equal. Netflix sorts its traffic into three classes: 1

  • NON_CRITICAL: logs and background requests. They do not affect playback, but they are a large share of load.
  • DEGRADED_EXPERIENCE: features like viewing history and pause markers. Users notice, but can still play.
  • CRITICAL: if this fails, the user sees an error when they press play.

Zuul gives each request a score from 1 to 100 as its first step. 1 Under overload it drops requests below a moving threshold. A cubic curve moves the threshold slowly at first, then sharply. At 35% overload the threshold is still in the mid-90s. At 80% it reaches 50. 1

Google uses four levels: CRITICAL_PLUS, CRITICAL, SHEDDABLE_PLUS and SHEDDABLE. 3 Amazon adds useful hints. The load balancer's health check is "the most important request" a server gets. Requests that finish work already started beat requests that start new work. 2

In a shop, that could mean: payment and checkout first, product pages next, then prefetch, recommendations and batch jobs. Move batch work to a queue, so it can wait.

Here is a sketch of a server-side check. Lower classes get lower limits, so they are shed first:

LIMITS = {"critical": 200, "degraded": 150, "sheddable": 100}

def admit(req, in_flight):
    if req.deadline_left_ms() <= 0:
        return reject(503)  # the caller has given up
    if in_flight >= LIMITS[req.priority]:
        return reject(503, retry_after_s=5)
    return None  # accept the request

Drop work nobody waits for

A request whose caller has gone is pure waste. Amazon suggests clients send a timeout hint, so the server can "drop doomed requests at little cost". 2 Google says to check the time left at each stage, before more work. 4 You met deadline propagation in Backoff, jitter and retry budgets.

Keep queues small. For steady traffic, Google suggests 50% of the thread pool size or less. 4 Amazon also caps how long a request may wait in a queue. 2

Queue order: controlled delay and adaptive LIFO

Facebook found that "many of our worst incidents" had large numbers of requests waiting in queues. 5 In 2015, Facebook described using two ideas together.

Controlled delay, a variant of the CoDel algorithm from network research. If the queue has not been empty in the last 100 ms, a new request may wait only 5 ms. Otherwise it may wait up to 100 ms. 5 Short bursts still queue, but a standing queue cannot form. Facebook found these values work well for most services, without tuning for each one. 5

Adaptive LIFO. In a long queue, the oldest request's user may have already left. So the server uses FIFO normally, then switches to LIFO when a queue starts to form. 5 The newest requests then have the best chance to finish in time.

Clients can help: adaptive throttling

A rejected request still costs the server something. So Google's clients throttle themselves. Google calls this adaptive throttling. Each client counts requests (attempts) and accepts (accepted by the backend) over the last 2 minutes. 3 Once requests passes K times accepts, the client starts rejecting some new requests locally, without sending them. The chance grows as the backend accepts less:

K = 2.0  # Google's usual choice

def reject_chance(requests, accepts):
    # counts from the last 2 minutes; requests includes local rejects
    return max(0.0, (requests - K * accepts) / (requests + 1))

A lower K throttles harder. 3 Facebook's clients also cap requests in flight to each service and fail extra ones at once. 5

Send the right signal

Use 503 for "I am overloaded". It means a temporary overload, and the server may add Retry-After. 7 Keep 429 for a client that sent too many requests, as in the rate limiting lesson. 6

The signal must calm clients down, not cause a retry storm. When Zuul sheds, it tells devices how many retries they may make, and in what time window. 1 Google advises not to retry when many backend tasks are overloaded. Let the error go back to the caller. 3

Degrade gracefully

Shedding drops whole requests. Degradation does less work per request. Google's examples: search a smaller in-memory set instead of the disk, or use a cheaper ranking. 4 Its example service stops returning pictures and small maps when capacity runs short. 4 Other choices: serve stale cached data, as in Caching and cache stampedes. Or turn off optional features with a kill switch.

Degraded modes should rarely run. Exercise them anyway, and alert when many servers use them. 4

Test it

Amazon's rule is direct. If you have not load tested "far beyond the point where it breaks", expect the worst way of failing. 2 The ideal result: goodput levels off near full use, instead of falling. 2

Netflix also tests what users see when traffic is shed. In production experiments, a small group of users has a range of priorities throttled for 45 minutes. 1 The first run found a race condition on Android and iOS, in a low-priority request that caused playback errors. 1

Section 4 of 8

Trade-offs

OptionProtects goodput?CostUse it when
No limit, unbounded FIFO queueNo Goodput falls close to zero.Nothing until the spike.Never for user-facing services.
Bounded queue, reject when fullYes , partly.Drops at random, not by importance.A first, simple step.
In-flight limit per priority classYes You must label every request and keep labels right.Mixed traffic, like checkout and prefetch.
Deadline checksYes Removes wasted work.Clients must send a deadline or timeout hint.Long call chains.
Controlled delay + adaptive LIFOYes Newer requests overtake older ones.Server queues under bursty load.
Client adaptive throttlingYes Saves the cost of rejecting.Some requests fail without trying.Many clients call one backend.
Graceful degradationYes Less work per request.Users get less. Rare code paths can break.Optional parts of a response.

Simple rule: a small bounded queue, an in-flight limit per priority class, and deadline checks. Add degradation for optional features, and test it all with load tests.

Section 5 of 8

At work: how a senior uses this

  • Ask of every service: "At twice our peak, what fails first? Did we choose that?"
  • Write down the priority class of each endpoint with the product owner. Payment is not the same as a recommendations widget.
  • Watch goodput, not only throughput. Count requests that finished in time and without error, and tie it to your SLOs.
  • Count shed requests by class and alert when critical traffic is shed.
  • Load test past the breaking point before big events. Check that goodput levels off.
  • Review client retry rules. They should honor Retry-After and stop when most calls fail.
Section 6 of 8

With AI

What to ask the agent

"Add an admission check to this service. Count requests in flight. Read a priority from the X-Priority header (critical, degraded, sheddable). Reject over a per-class limit with 503 and Retry-After, before parsing the body."

"Propagate the client deadline through every call in this handler. Before each downstream call, drop the request if less than 50 ms is left."

"Write a load test that ramps from 50% to 300% of measured capacity. Plot throughput, goodput and p99 latency per priority class."

What to check yourself

  • The rejection happens before any expensive work: no body parsing, database call or downstream call.
  • Shed requests get 503, and the client code honors Retry-After.
  • Health checks are never shed.
  • Every endpoint has a priority, and unknown traffic gets a low class, not critical.
  • The load test shows checkout latency staying flat while low-priority traffic is shed.
Section 7 of 8

Check yourself

1. A server can finish 1,000 requests a second. 1,500 a second arrive, and it queues the extra in FIFO order with no limit. Clients give up after 1 second. What happens after a few seconds?

Show answer

The server finishes about 1,000 a second, but almost every answer comes after its caller gave up. The queue grows by 500 a second, so the wait soon passes 1 second. The server stays busy, but goodput falls close to zero.

2. What is the main difference between a rate limit and load shedding?

Show answer

A rate limit is usually per client and fixed ahead of time. Load shedding reacts to the server's own state, such as CPU or requests in flight. A rate limit stops one client using more than its share. Load shedding protects the server when total load is too high, whoever sends it.

3. In Netflix's taxonomy, which traffic is shed first?

Show answer

NON_CRITICAL, such as logs and background requests. Shedding starts with the lowest priority. Logs and background requests do not affect playback, and they are a large share of the load.

4. Under Facebook's adaptive LIFO, when does the server switch from FIFO to LIFO?

Show answer

When a queue starts to form, because the oldest requests are the most likely to be abandoned. In normal times the queue is short and FIFO is fair. Under queuing, the newest request is the one most likely to still have a waiting user.

5. With Google's adaptive throttling (K = 2), a client made 100 requests in the last 2 minutes and the backend accepted 30. About what share of new requests does the client reject locally?

Show answer

About 40%: (100 − 2 × 30) / 101. The rejection chance is max(0, (requests − K × accepts) / (requests + 1)). That is 40 / 101, about 40%.

Your progress is saved only in this browser. Export it to keep it safe.

Was this clear?
Report a mistake (opens GitHub in a new tab)
Section 8 of 8

Go deeper

Show 7 sources and related lessons
  1. Manuel Correa, Arthur Gonigberg and Daniel West, “Keeping Netflix Reliable Using Prioritized Load Shedding”, Netflix TechBlog, 2 November 2020 (opens in a new tab)
    Netflix's three request classes, the priority score in the Zuul gateway, the cubic shedding curve, and how they test it in production.
  2. David Yanacek, “Using load shedding to avoid overload”, Amazon Builders' Library (now AWS Builder Center), 2019 (opens in a new tab)
    Goodput, why a timed-out request is wasted work, timeout hints, and how Amazon load tests past the breaking point.
  3. Alejandro Forero Cuervo, “Handling Overload”, Site Reliability Engineering (Google, O'Reilly 2016), chapter 21 (opens in a new tab)
    Criticality classes, client-side adaptive throttling with its formula, and when not to retry.
  4. Mike Ulrich, “Addressing Cascading Failures”, Site Reliability Engineering (Google, O'Reilly 2016), chapter 22 (opens in a new tab)
    Load shedding versus graceful degradation, queue sizes, deadlines, and load testing until things break.
  5. Ben Maurer, “Fail at Scale”, ACM Queue, volume 13, issue 8, 2015 (opens in a new tab)
    Facebook's controlled delay queue, adaptive LIFO and client-side concurrency limits, each in a few paragraphs.
  6. Nottingham and Fielding, RFC 6585: Additional HTTP Status Codes (IETF, 2012), section 4 (opens in a new tab)
    The definition of 429 Too Many Requests.
  7. Fielding, Nottingham and Reschke, RFC 9110: HTTP Semantics (IETF, 2022), section 15.6.4 (opens in a new tab)
    The definition of 503 Service Unavailable and its link to Retry-After.

Case studies: Amazon: Why queue backlogs can turn a short outage into a long one · Netflix: Adaptive concurrency limits instead of hand-tuned limits · Shopify: Surviving flash sales with a checkout queue at the load balancer · Stripe: Two rate limiters and two load shedders that protect an API

Related: Rate limiting · Circuit breakers, bulkheads and fallbacks · Backoff, jitter and retry budgets · Tail latency and queueing · Caching and cache stampedes · Queues vs logs and delivery guarantees · Observability, SLOs and error budgets

Term

See full entry

Jump to a section

  1. 1What broke
  2. 2The idea in simple words
  3. 3How it works
  4. 4Trade-offs
  5. 5At work
  6. 6With AI
  7. 7Check yourself
  8. 8Go deeper