Degradación Elegante
Load shedding · Fallbacks
Escrito por Darjus Kazakevic · revisado el
Shed the optional path first, so the core path keeps answering.
A page is usually one essential thing and several nice ones. On a product page, the product and its price are essential; reviews and recommendations are not. Without a decision, they fail together: the recommendations service times out and the product page returns 500. Graceful degradation ranks the parts and gives each optional one a cheaper answer.
The tools are the ones fault tolerance uses, such as timeouts and circuit breakers. The principle is the product decision behind them. The cost is that degraded states must be designed and watched. A page that silently loses its reviews for a month is not degrading gracefully. It is broken quietly.
En esencia — Decide in advance which parts are essential, and under failure or overload drop the optional ones instead of failing the whole page.
Cuándo recurrir a él
Recurre a él cuando
- A page combines one essential part with several optional ones
- Overload where some requests, like checkout, matter more than others
- Third-party widgets or APIs you do not control are on the page
Reconsidéralo cuando
- Every part is essential — a partial answer would be a wrong answer
- A fallback would mislead, like a stale price shown as current
- A batch job with no user waiting — retry it later instead
Conceptos clave
- Essential and optional parts
- Rank each part of a response by what the page is worth without it. Essential parts may fail the request. Optional parts must never do so.
- Fallback
- The cheaper answer for an optional part. It can be empty, stale or static, and the choice depends on what is still useful to the user.
- Shedding by priority
- Graceful degradation for traffic. Under overload, refuse low-priority requests first, such as bots, prefetches and analytics, so high-priority ones like checkout still get through.
- Kill switch
- A feature flag that turns an expensive feature off at runtime, without a deploy. During an incident, an operator turns off search suggestions to protect checkout.
Reglas de diseño
- Rank the parts before the incident
- Decide what each page is still worth without each part. The essential call may throw; every optional one gets a short timeout and a cheaper answer, such as an empty list or a cached value.
- Count every fallback
- A degraded state nobody can see is a hidden bug. Increment a metric per part each time it falls back, so “degraded for a minute” never quietly becomes “broken for a month”.
- Never fall back to a wrong answer
- A stale price, an old balance or a skipped permission check is worse than an error. Degrade only what the user would rather lose than see wrong.
- Look at the degraded page
- Turn off each optional dependency in staging, or behind a flag in production, and look at the result. The first time anyone sees a fallback should not be during an incident.
Errores habituales
- A fallback that calls the same failing service. The cheap path times out too, and the page waits twice.
- Hiding a panel with no metric. Reviews disappear for weeks, and nobody notices until sales drop.
- Treating everything as essential. One missing banner fails the whole page.
- Shedding by arrival order instead of priority. Checkout requests are refused while bot traffic is served.