# Graceful degradation

> Serve a simpler page instead of an error page when a non-critical part is down.

Concept · Reliability · https://levelcode.org/concepts/graceful-degradation

Graceful degradation means a system keeps providing its most important function when parts of it fail, by dropping or simplifying the rest. A product page without recommendations is a small loss; a product page that errors because recommendations timed out is an outage.

## Classify features

- **Essential:** the user's reason for being there — viewing the product, checking out, sending the message.
- **Optional:** everything that decorates it — recommendations, reviews, personalisation, badges, live counts.

Optional dependencies get short [timeouts](https://levelcode.org/concepts/timeouts), [circuit breakers](https://levelcode.org/concepts/circuit-breakers) and a fallback, and must never be able to fail an essential path.

## Fallback options

| Dependency down | Fallback |
|---|---|
| Recommendations | Popular items, or hide the section |
| Personalisation | The generic version of the page, possibly from a CDN |
| Search | Browse by category; show "search is temporarily unavailable" |
| Reviews | Hide the section, keep the average rating if cached |
| Primary payment provider | A secondary provider, or accept the order and charge later |
| Live inventory | Last known stock level, confirmed at checkout |

## Make it operable

- **Feature flags / kill switches** let operators turn off expensive optional features during an incident, freeing capacity for essential ones.
- **Static or cached fallbacks** at the edge: serve a stale cached page (`stale-if-error`) when the origin is failing.
- **Tell users honestly** when something is degraded, rather than showing empty sections that look like bugs.

## Test it

A fallback that's never exercised often doesn't work. Inject failures into optional dependencies in staging (and carefully in production) and confirm the essential path stays within its SLO ([SLIs, SLOs and error budgets](https://levelcode.org/concepts/sli-slo-sla)).
