GOAT EngineerPreparing your learning space…

System Design · Concept Library · Free article

Edge Load Shedding — drop the right work, at the cheapest place

Why the fix for overload is to deliberately refuse some requests — as early and cheaply as you can — so the rest stay healthy. The economics of where you reject, shed-vs-throttle-vs-queue, graceful degradation, and the congestion collapse it prevents, for interns through principal engineers.

When more traffic arrives than a system can handle, trying to serve all of it serves none of it well — past capacity, everything slows, clients time out and retry, and the retries pile on until useful work collapses toward zero (congestion collapse). Load shedding is the deliberate fix: refuse the excess so the rest stays healthy. Two levers make it cheap and smart. Where: reject as early as possible — a 429 at the edge or CDN costs almost nothing, while the same rejection from your app has already burned a connection, a thread, and memory, so shedding at the door protects everything behind it. What: drop the least valuable work first (analytics before checkout, anonymous before paying), so a spike degrades gracefully instead of taking everything down equally. The 429 a rate limiter returns is one instance of this; the discipline is bigger than rate limiting.

The flood that got inside before you stopped it

Hatch built its rate limiter, but wired it in one step too late: the limit is checked inside the application, after the request has already been accepted, routed, and handed to a worker thread. Then the 50,000-QPS botnet hits. Each junk request sails through the front door, ties up an app-server thread while the app finally decides "over the limit, reject," and only then gets its 429. The threads fill with garbage faster than they drain, legitimate requests queue behind the junk, and p99 rockets past 5,000ms. The rate limiter is technically "working" — it is returning 429s — and the site is still on its knees, because saying "no" this deep in costs almost as much as saying "yes."

Load shedding: refuse some, so the rest survive

The name comes from the power grid: when demand exceeds what the network can supply, the operator deliberately cuts power to some areas (a rolling blackout) rather than let the whole grid collapse. Software does the same. Load shedding is deliberately dropping — or delaying — some requests when you’re overloaded, to keep the system healthy for the rest. It feels wrong the first time ("I’m choosing to fail requests?"), until you see the alternative: a system that accepts everything under overload doesn’t serve everyone a little slower — it serves no one, because it falls over. Better to cleanly serve 90% than to melt trying to serve 100%.

What happens if you don’t: congestion collapse

Here’s the part that surprises people: past capacity, a system without shedding doesn’t just plateau — its useful output falls. As requests pile up, each one waits longer; waits turn into timeouts; timed-out clients retry, adding fresh load on top of the load that was already too much; and now the server is doing more total work while completing less of it. Fewer requests succeed, so more get retried, so fewer succeed — a downward spiral. The metric that matters is goodput (work actually completed successfully, not just requests accepted), and it collapses toward zero. Push the load past capacity below and watch the two curves diverge:

The interactive version of this example is available when JavaScript loads.

Where you shed decides what it costs

If you’re going to refuse a request, refuse it at the first place you possibly can, because every layer it passes through spends real resources on it. A request rejected at the edge or CDN costs about as little as a rejection can — you accept a connection and return a tiny 429, and the junk never even enters your network. The same rejection from an app server has already cost a load-balancer hop, a gateway route and auth lookup, a worker thread pulled from the pool, memory to buffer the request, and the CPU to parse it — all spent just to end up saying "no." Drag the rejection point inward and watch the bill climb:

The interactive version of this example is available when JavaScript loads.

This is exactly the break from the top of the page. The rate limiter that checks inside the app is paying app-server prices for every "no"; moving the check to the edge or the load balancer / gateway — the first point that has enough context to recognise the abuse — drops the junk before it can touch a thread. The rule of thumb: enforce coarse, high-volume limits as far out as you can (the edge sheds floods for pennies), and save the deeper layers for the fine-grained limits that genuinely need application context.

429 vs 503 — whose fault is the "no"?

When you shed, the status code you return tells the client why, and there are two that matter. 429 Too Many Requests means "you, specifically, are over your limit" — the rejection is about this client’s behaviour, and it’s what a rate limiter returns. 503 Service Unavailable means "I, the server, am overloaded right now" — the rejection is about the system’s health, not any one client, and it’s what you return when you’re shedding globally to survive a spike. Both should carry a Retry-After so clients back off instead of hammering (the header details are on the rate limiting page). Getting the two right matters because they mean different things to the client and to your dashboards: a wall of 429s says "someone is abusing us"; a wall of 503s says "we are underwater."

Shed, throttle, or queue

Dropping isn’t the only way to handle more than you can take — there are three responses, and they trade off differently:

  • Shed (drop) — reject the excess immediately with a 429/503. Cheapest and instant; the client gets a fast, honest "no." Lossy by design. This is your default under a flood.
  • Throttle (slow down) — admit the request but pace it, so the client proceeds at a rate you can sustain (the leaky bucket does this). Kinder to legitimate bursts, but it holds resources while it waits.
  • Queue (buffer) — accept the request into a buffer and serve it when you can. Smooths short spikes beautifully — but a queue under sustained overload just fills up, adds latency to everything in it, and eventually you’re shedding anyway (from a full queue) after having paid to hold all that work. A queue is a shock absorber, not a capacity increase.

Shed the least valuable work first

Once you accept that you’ll drop some traffic under overload, the obvious next question is which. Dropping at random is a waste — you’d fail paying customers and background analytics with equal probability. Instead you rank traffic by value and shed from the bottom up: a live checkout matters more than a logged-in browse, which matters more than an anonymous visit, which matters far more than a background analytics ping. Under load, drop the analytics first, then the anonymous traffic, and only touch the valuable tiers if you absolutely must. Raise the load and watch the low tiers get shed while the top stays whole:

The interactive version of this example is available when JavaScript loads.

This is graceful degradation — the system gets less capable under stress instead of falling over. It has a close cousin worth naming: serving a degraded response that’s cheaper to produce. Under heavy load you might skip the personalised recommendations and show a generic list, drop the real-time inventory count and show "in stock," or serve a slightly stale cached page instead of a fresh one. A less-perfect answer that’s cheap to compute keeps the core experience alive when the full one would tip you over. The instinct is the same: spend your scarce capacity on what matters most.

Backpressure: tell the sender to slow down

Shedding refuses work at your own door. Backpressure is the complement: instead of silently absorbing or dropping, you signal upstream that you’re near your limit so the sender slows down before it overwhelms you. A bounded queue that rejects when full is backpressure; a 503 with Retry-After is backpressure; a service telling its callers "I’m at capacity" is backpressure. The most elegant version pushes all the way to the source: client-side throttling, where well-behaved clients notice they’re getting rejected and voluntarily cut their own request rate — which stops the retry-amplification spiral at its origin, before it ever becomes your problem. Shedding and backpressure work together: shed to protect yourself right now, and apply backpressure so there’s less to shed.

Measuring it

  • Goodput, not just throughput — track requests completed successfully, not requests accepted. Under overload the two diverge, and goodput is the one that matters.
  • Shed rate — how much you’re dropping, split by tier and by reason (429 vs 503). A rising shed rate is your early warning of overload.
  • What you’re shedding — are you dropping analytics (fine) or checkouts (alarm)? Shedding the wrong tier is worse than shedding too much.
  • Where you’re shedding — 429s from deep in the app instead of the edge means junk is still penetrating; move the check outward.
  • Latency of the "no" — a rejection should be fast; a slow 503 means you’re paying to refuse, which defeats the point.

Pitfalls

  • Shedding too deep — rejecting inside the app pays app-server prices for every "no"; push coarse shedding to the edge/gateway.
  • Unbounded queues — they turn "fail fast" into "fail slow after wasting resources"; bound them and shed when full.
  • Random shedding — dropping without priority fails paying users and background jobs alike; rank by value.
  • Retries with no backoff or jitter — the amplifier behind congestion collapse; require exponential backoff + jitter, ideally client-side throttling.
  • Confusing 429 and 503 — client-over-limit vs server-overloaded mean different things to clients and dashboards; use the right one.
  • No Retry-After — a rejection with no guidance invites a tight retry loop that deepens the overload.

Best practices

  • Shed as early as possible — coarse, high-volume limits at the edge/CDN/gateway; deep layers only for limits that need app context.
  • Prefer a fast "no" to a slow one — bound queues, fail fast, and make rejections cheap.
  • Rank traffic by value and shed the least valuable first — graceful degradation over uniform collapse.
  • Serve degraded responses under load — a cheap, less-perfect answer beats no answer.
  • Apply backpressure and client-side throttling — stop the retry spiral at the source, not just at your door.
  • Return the right code with Retry-After — 429 for per-client limits, 503 for global overload; always tell them when to come back.
  • Alert on goodput and on shedding valuable tiers — those are the signals that overload is hurting the business.

The interview deck

What is load shedding? (intern)
Deliberately dropping or delaying some requests when you’re overloaded, to keep the system healthy for the rest. Better to serve 90% well than to melt trying to serve 100%.
Why not just accept everything and do your best? (SDE2)
Past capacity, useful work (goodput) doesn’t plateau — it collapses. Requests slow, clients time out and retry, retries add load, fewer succeed. That spiral is congestion collapse, and it can be metastable (it stays collapsed even after the spike passes).
Where should you shed, and why does it matter? (SDE2 → senior)
As early as possible — the edge/CDN/gateway. A rejected request still costs everything it touched on the way in, so a 429 at the edge is nearly free while one from the app has already burned a thread and memory. Shed coarse floods at the door; keep deep layers for context-dependent limits.
429 vs 503? (senior)
429 = this client is over their limit (about the client). 503 = the server is overloaded (about the system). Both carry Retry-After. A wall of 429s means abuse; a wall of 503s means you’re underwater.
How do you decide what to drop? (senior → staff)
Rank traffic by value and shed the least valuable first — analytics before anonymous before logged-in before checkout — so the system degrades gracefully instead of failing uniformly. Pair it with degraded responses (cheaper, less-perfect answers) and backpressure/client-side throttling to cut the load at its source.

The one thing to carry

You cannot always control how much traffic arrives, only what you do with the excess — and doing nothing is the one option that fails everyone. Load shedding is the discipline of refusing work on purpose to protect the work you keep: refuse it early, where a "no" is cheap, and refuse the least valuable first, so a flood degrades your system instead of drowning it. The 429 a rate limiter hands a bot is the smallest example of a much bigger reflex — under overload, a fast, cheap, well-chosen "no" is what keeps the "yes"es flowing.

By GOAT Engineer. Back to Concept Library. Privacy Policy · Contact.