Graceful degradation: what to switch off first
One slow service, one box on the page, and every user gets an error. Here is how to decide in advance what can go missing, and how to serve a smaller page, shed load and keep the core working instead.
01 One slow box takes down the page
A shop's product page shows the product, its price, reviews and a "you may also like" box. On the busiest day of the year the recommendations service slows down. The page waits for it, the page server's threads fill up with waiting requests, and soon every product page returns 500. Nobody can buy anything, because of a box most shoppers ignore.
Graceful degradation means deciding in advance what the page can do without, and serving a smaller page instead of an error when part of the system is slow, broken or overloaded.
02 Why every extra dependency costs uptime
If a page needs every one of its dependencies to answer, its chance of working is the product of theirs. Five services that are each up 99.9% of the time give a page that works about 99.5% of the time, five times the downtime of any one of them.
0.999^5 ≈ 0.995. Any one failing fails the page.So the first step is a list: for each thing on the page, is it required or optional? Usually far fewer things are required than the code assumes.
03 Time budgets and fallbacks for optional calls
An optional call needs two things: a short time limit, and an answer to use when the limit passes. The limit matters as much as the fallback. A call that fails fast is easy to degrade; a call that hangs holds a thread, a connection and the user's patience.
- just sent
- timed out
- page served
A shopper opens a product page. The page needs the product and its price, which it cannot do without, and recommendations, which are nice to have. The recommendations service is overloaded today.
That is a real run on Node 24. The page is ready in under 200 ms even though recommendations take 900. The losing promise keeps running in the background; in a real service, pass an AbortSignal to the HTTP call so the work is cancelled too.
04 Decide what to switch off first
Under pressure, nobody should be deciding what matters. Write it down before the incident: what each feature is worth, what it costs, and what replaces it.
| Feature | If it is missing | Fallback |
|---|---|---|
| Posts from people you follow | The app is broken | None: keep it up at all costs |
| Posting and comments | Users cannot take part | Queue writes and show them as pending |
| Ranked order | Feed feels less relevant | Newest first |
| Like and view counts | Numbers look stale | Cached or approximate counts |
| People you may know | Nobody notices on the day | Hide the box |
| Autoplay video | Videos need a tap | Show a still image |
Notice the middle column. The goal is not "on or off" but cheaper: an older copy, a simpler algorithm, an approximate number, a static image. A cached page from a minute ago is often better than a fresh one that never arrives.
05 Switching off under load
Failures are not the only trigger. When load passes what the system can serve, turning off expensive optional work frees capacity for the core. The switches are usually feature flags or kill switches that an operator, or an automatic rule on load, can flip without a deploy.
- switched off
- cheaper version
- just taken
- request shed
A news feed at a normal hour. Every feature is on. The team has already ranked them: the posts are the product, everything else can go.
A fallback that has never run is probably broken. Flip your kill switches regularly in production, during quiet hours or in planned game days, and check the page still renders. Teams that only find out on the bad day often learn the fallback calls the same overloaded service.
06 Shedding load: a fast no beats a slow yes
When even the core cannot keep up, the server must refuse some requests. Refusing early is cheap: a 503 costs almost nothing to send. Accepting everything means every request gets slow, many time out on the client, and the server spends its time on work nobody is waiting for any more.
503 with Retry-After. The rest are served at normal speed.- Shed by priority. Background refreshes, prefetching and analytics go before a user tapping "buy". Mark priority on the request, for example in a header set at the edge.
- Limit concurrency, not just rate. Cap the requests in flight per server; when the cap is reached, reject instead of queueing.
- Drop requests that waited too long. If a request has been queued longer than the client's timeout, the client has already given up. Skip it.
- Shed at the edge. The earlier a request is refused, the less work was spent on it.
07 How degradation goes wrong
timeout: 30000Library default timeoutsMany HTTP clients wait 30 seconds or more, or have no overall request timeout at all, unless you set one. An optional call with a default timeout is not optional; it just fails slowly.