The problem: too much at once
A celebrity posts a Snip link to 50 million followers, and redirects jump to three times Snip's usual peak. Snip can add servers, but that takes minutes, and the spike is now.
Without a plan, here's what happens. Requests arrive faster than servers finish them, so they queue. Each request waits longer, until it's waiting longer than the client's timeout. The client gives up and retries, adding more load. The server eventually reaches each abandoned request and does the full work anyway, for nobody. It's busy at 100%, and almost none of its work is useful.
That's the key distinction:
- Throughput is how many requests a second the server handles.
- Goodput is how many it handles in time for the client to use the answer.
Past capacity, throughput can stay high while goodput collapses towards zero. The goal of this lesson is to keep goodput at capacity even when demand is far beyond it.
Backpressure: bounded queues
Every queue in a system should have a limit. When it's full, the producer is told so, and slows down or fails fast, instead of the queue growing without end. That push upstream is backpressure.
- A server's request queue that's full answers new requests with
503straight away. - A job queue that's full makes producers wait, or reject new jobs, instead of holding hours of backlog.
- A client that sees backpressure (a
503or429, maybe withRetry-After) backs off (03.09 Timeouts, retries, backoff and jitter).
Unbounded queues feel safe ("we never drop anything!"), but all they do is turn an overload into very high latency and, eventually, running out of memory.
Load shedding: say no early and cheaply
Load shedding is a server deciding, as each request arrives, whether it has room to serve it well. If not, it rejects it immediately with a cheap error, before doing any real work. A rejected request costs microseconds; an accepted one that times out costs the full work and helps nobody.
Common signals for "no room": too many requests in progress, a queue past its limit, CPU above a threshold, or recent latency climbing towards the timeout.
Not all requests are equal
When you must turn some work away, choose which. Snip ranks its traffic:
| Priority | Traffic | Why |
|---|---|---|
| 1 | Load balancer health checks | Fail these and the load balancer removes the server, making everything worse. |
| 2 | Redirects | The core promise; every failed redirect is a broken link on someone else's site. |
| 3 | Creating links | Important, but a short delay is tolerable, and clients can retry with idempotency keys. |
| 4 | Dashboard and stats | Owners can wait a minute. |
| 5 | Bulk exports and reports | Can be paused entirely during a spike. |
As load rises, Snip sheds from the bottom of the table up.
Don't work on requests nobody is waiting for
Two more habits keep goodput high:
- Deadlines. The client sends how long it will wait (or each hop passes on the time remaining). A server that picks up a request whose deadline has already passed drops it instead of doing it. A request halfway through that runs out of time stops early.
- Graceful degradation. Instead of failing outright, return something cheaper: a cached stats page from a minute ago, the dashboard without its live counter, the redirect without recording the click.
Seen in production
Amazon
2019Builders' Library
Amazon distinguishes throughput, all the requests sent to a server, from goodput, those handled without errors and fast enough for the client to use. A server near overload should reject excess requests so that it can reply to the ones it accepts before the client times out. The article names the load balancer's ping as the most important request a server receives, and describes passing the remaining time between hops so servers can stop work on requests that are already doomed.
What we foundShedding excess load keeps goodput high; prioritise the requests that matter and drop ones whose clients have already given up.
Using load shedding to avoid overloadaws.amazon.com ↗Snip's redirect servers are overloaded. Each request now queues for 3 seconds; clients time out after 1 second. CPU is at 100%. How much useful work are the servers doing?
Recap
Interview questions
Your service gets three times its capacity in traffic for ten minutes. What should happen?