What it is
Graceful degradation means a system keeps delivering its most important function, with reduced features, older data or less capacity, when parts of it fail or are overloaded, instead of failing completely. The opposite is a system where any failing piece produces an error page.
Why it exists
Every service has dependencies, and some of them will be down or slow at any given moment. If a page needs all ten of its dependencies, its availability is roughly the product of theirs, and an optional widget can take down checkout. Overload behaves the same way: without a decision about what to drop, the system drops a bit of everything, including the requests that matter most.
How it works
Classify dependencies. For each call ask: can the response be useful without it? A product page needs the product; it does not need recommendations, reviews or a personalised banner. Optional calls get short timeouts and circuit breakers, and the page renders without them.
Fallback paths. Things that can answer without the failed dependency:
- Cache: entries already cached keep serving; with a cache in front, a database outage fails only the misses.
- Stale data: keep entries past their TTL and serve them while the source fails (HTTP's
Cache-Control: stale-if-errorandstale-while-revalidate, RFC 5861). Label what may be outdated. - Safe defaults: a generic "popular items" list, a default configuration, a cached feature-flag snapshot.
- Reduced functionality: read-only mode, search without facets, queueing an action for later ("we'll email your receipt").
Load shedding. When demand exceeds capacity, reject some work early and cheaply so the rest succeeds. Shed by priority: bots, prefetch, analytics and batch jobs first; paying users' critical journeys last. Static budgets per traffic class are simple; adaptive shedders reject based on queue time, concurrency or CPU (for example, rejecting when requests have waited longer than they could still succeed). Return 429 or 503 with Retry-After so well-behaved clients back off.
Brownouts and kill switches. Feature flags that turn expensive features off under load or during an incident, ideally automatically, so the decision does not wait for someone to find the right config.
When to use it
On every user-facing path with more than one dependency, and for any service that can be overloaded by traffic it does not control (public APIs, crawlers, retry storms after an outage).
When not to
- When a wrong answer is worse than no answer: payments, permissions, medical or financial data that must be current. Fail closed, clearly.
- When the fallback costs more than the failure it hides: a degraded mode that is never exercised adds code that may itself fail.
- As a substitute for capacity planning: shedding is for spikes and incidents, not for permanent under-provisioning.
Trade-offs
| Choice | You gain | You pay |
|---|---|---|
| Serve stale on error | Most pages keep working | Users may act on outdated data; needs labels and checks at commit points |
| Optional features with fallbacks | Their outages stay invisible | More code paths to test; product decisions per feature |
| Static per-class budgets | Simple, predictable shedding | Wasted capacity when the high-priority class is quiet |
| Adaptive shedding | Uses capacity fully, reacts to real overload | Harder to reason about and tune |
| Fail open (allow when the checker is down) | Availability | Risk of letting through what should have been blocked |
Alternatives
- More redundancy for the dependency itself (replicas, failover): fixes the cause instead of hiding it, but costs more and never reaches 100%.
- Asynchronous processing: accept the request into a queue and finish later, so a slow dependency does not block the user.
- Static fallback pages served from a CDN when the origin is completely down.
Failure modes
- Optional dependency, hard in practice: no timeout or no fallback, so a slow recommendations service hangs the page.
- Fallback never tested: the stale path has a bug, or the default config is years old.
- Silent staleness: users see outdated prices or stock without any hint.
- Shedding the wrong traffic: rejecting by arrival order instead of value; or shedding after expensive work has already been done.
- Retry storms: shed clients retry immediately and multiply the load; send
Retry-Afterand use backoff with jitter.
In production
List the degraded modes per user journey before an incident: what turns off, what goes stale (and for how long), what is shed first. Wire them to circuit breakers and feature flags, and test them with fault injection and game days. Monitor per traffic class: success rate and latency for checkout, browse and bots separately, plus how often fallbacks are used, because a fallback that serves 30% of traffic hides a real outage.
Common misconceptions
- "Failing fast is graceful." It protects the servers; the user still gets an error unless there is a fallback.
- "A higher error rate after adding shedding means it made things worse." Shed errors are deliberate; look at the important traffic.
- "Stale data is always wrong." Much data (descriptions, images, catalogue structure) is fine an hour old; decide per field.
- "Degradation is only an engineering decision." What may be turned off or shown stale is a product decision; make it ahead of time.
Interview angle
When drawing a page that calls several services, say which dependencies are critical and which degrade, and how: timeouts, circuit breakers, cached or stale fallbacks, defaults. For overload, describe priority-based shedding at the edge and why it beats letting every request time out. Interviewers like hearing that you would measure success per journey and test the degraded modes regularly.
Model assumptions
The engine runs all traffic and failures. Arrivals are Poisson: shoppers 150 req/s, bots and prefetch 60 req/s (400 during the surge). The Product API has 20 workers, a 30 ms mean service time (lognormal, cv 0.35) and room for 64 waiting requests. The database has 10 connections and 20 ms mean reads. The cache answers a fixed share of requests (70% hits) in about 1 ms; on a miss with the database down the request fails at once (connection refused). Serving stale on error is modelled as the hit ratio rising to 97% while the database is down. The low-priority lane stands for a gateway that classifies requests; its shedding is a token bucket of 60 req/s (burst 20). Numbers are illustrative, not benchmarks. Latency percentiles (P50, P95, P99) are computed over the requests that succeeded in the last 5 simulated seconds: failed, rejected and timed-out requests are not in them and are counted in the Errors tile, which is always shown next to them. Rejecting or timing out the slowest requests therefore improves the percentiles while making the system less reliable, so read the two together.