Load shedding and admission control
Reject some work early and cheaply so the rest is served well.
15 min readSaying no is a feature
Every system has a maximum throughput. When demand exceeds it, the choice is not whether requests fail but which ones and how. Without load shedding, every request slows down until all of them time out. With it, the server rejects the excess immediately with a cheap 503 or 429 and keeps serving the rest at normal latency. Serving 80% of users well beats serving 100% of users a timeout.
Admission control signals
Decide at the front door, before expensive work starts. Useful signals are concurrency (in-flight requests above a limit), queue time (a request has already waited too long), and CPU or latency targets. Concurrency limits are the most robust because they follow directly from Little's law; adaptive limiters raise the limit while latency stays low and cut it when latency rises, finding capacity automatically rather than relying on a hand-tuned number.
Shed by priority
Not all work is equal, so do not shed it equally. Classify requests by how much users and the business lose when each one fails, then shed from the bottom of that list upwards as load rises. Keep the number of classes small, three or four, so everyone can remember them.
- Critical: checkout, login, payments; shed last
- Degradable: search suggestions, recommendations; serve from cache or skip
- Sheddable: analytics, prefetches, batch jobs and retries; shed first
- Tag priority at the edge and carry it on every downstream call
Shed early and cheaply
A rejection must cost much less than serving. If rejecting still parses the body, opens a database connection and logs a stack trace, an overloaded server spends its capacity on refusals. Reject at the load balancer or first middleware. Pair it with a waiting room or queue for bursts users will tolerate waiting for, such as ticket sales, where admitting users at a fixed rate is fairer than random failures.
Key takeaways
- Rejecting excess load quickly keeps latency normal for the requests you accept
- Concurrency limits, ideally adaptive, are the most robust admission signal
- Shed by priority: background and best-effort traffic first, critical paths last
- Rejection must be far cheaper than serving, so do it at the front door
Sign in to track lessons and earn badges.