LOAD SHEDDING

Drop some requests on purpose so you can serve the rest

L215 MINRELIABILITY
PREDICT

Capacity 100 req/s, clients time out after 2 s, load 120 req/s, every request admitted. After 30 seconds, how many requests per second complete in time?

A server handles 100 req/s and clients give up after 2 s. Send it 120 req/s and admit everything: the queue grows by 20 requests every second. After ten seconds the oldest request has waited 2 s, and from then on every request the server picks up belongs to a client that has already hung up. The server runs flat out and its goodput, work finished while someone still wants it, is zero.

Load shedding rejects the excess before it costs anything. Shed low priority first when the queue gets deep, and shed everything once the queue holds more work than any client will wait for. 80% of the traffic stays fast instead of 100% being useless.

▶ SIMULATION
CLIENTS (120% of capacity)
arriving: 0 req/s (96 high, 24 low)
rejected fast: 0 low · 0 high
gave up waiting: 0
client timeout 2 s
SERVER QUEUE
t = 0 s
queued: 0 (peak 0)
wait for the newest: 0 s
capacity 100 req/s · admit everything; queue is unbounded
SERVED (last second)
goodput: 0 req/s in time
wasted: 0 req/s served after the client left
longest wait served: 0 s
server busy: 0 of 100 req/s
goodput over the run0 served in time of 0 arrived
✓ goodput >= 80% of capacity (or of demand, if lower)✓ served requests are served before their client gives up (2 s)
SCHEDULE
01[CLIENTS]traffic starts at LOAD % of capacity (20% of it low priority)
02[CLOCK]+1 s
03[CLOCK]+1 s
04[CLOCK]+2 s
05[CLOCK]+2 s
06[CLOCK]+5 s
07[CLOCK]+5 s
08[CLOCK]+10 s
09[CLOCK]end of window: report
Start of serve everything scenario. 9 steps.
app.use((req, res, next) => next());          // admit everything
// At 120% load the queue grows 20 req/s. After ~10 s every request
// waits > 2 s, every client has hung up, and the server is 100% busy doing nothing useful.

Watch the invariant strip in SERVE EVERYTHING: goodput holds at 100 req/s while the queue grows, then, a little after the queue holds more than 2 s of work, it falls to 0 within a couple of seconds and both checks turn red. In FIX: SHED LOW PRIORITY the same 120 req/s arrive, the queue never passes 52, and goodput stays at 100 with no high-priority request rejected. SHED WITHOUT PRIORITY also keeps goodput, but 374 of its rejections are high priority.

TUNE IT NOT YET

Lower LOAD step by step. Find the lowest load at which serving everything ends the run with less goodput than shedding would at the same load.

GOAL: serve-everything goodput < shedding goodput at this LOAD, and not at LOAD − 10

FIX IT NOT YET

Rewrite admit so the server keeps its goodput through a burst at 150% of capacity: reject low-priority requests first when the queue is deep, reject everything once the queue holds a second of work, and reject nothing when there is room. Clients give up after 2 s.

Mental model:

Overload is not a throughput problem; it is a goodput problem. Past capacity, every request you admit makes every request behind it later, and once the queue is deeper than your clients’ patience the server serves only ghosts. So reject early, reject cheaply, and reject by priority: a fast 503 to the least important 20% is what keeps the other 80% fast. The signal is queue depth (or queueing delay), not CPU.

IN PRODUCTION

Admission control in Envoy and gRPC, max_requests limits, concurrency limiters like Netflix's adaptive limit, HTTP 503 and 429 with Retry-After, priority headers and request criticality in the Google SRE book. The symptom without it: servers at 100% CPU, dashboards green on throughput, users seeing nothing but timeouts.

IN INTERVIEWS

“Traffic is 20% above capacity. What happens, and what do you do?” Explain the queue growing until every request is served too late, then say you shed by priority on queue depth, serve the rest fast, and that the dropped 20% should get a fast rejection they can retry later with backoff. Mention that autoscaling is too slow to be the only answer.

RECALL CARDS Tap to flip. They join your review deck when you mark the lesson complete.

USED IN

Chapters that build on this lesson.

NEXT: CASCADING FAILURES →