Course map

Topic 154 / Core

Graceful degradation

Chapter 9.4 · Resilience Patterns

What and why

A circuit breaker (→ 151) and bulkhead (→ 153) stop a failing dependency from taking down the whole service — but "stop failing badly" still leaves the question of what the caller shows the user instead. Graceful degradation is deciding, per feature, at design time, what reduced behavior to offer when a dependency is unavailable — stale data, a default value, or a disabled feature — instead of an error page. Builds on: → 151 (circuit breaker — the open state needs a defined fallback).

Diagram

Dependency down Degraded behavior (decided in advance) Not this
Recommendations service Hide the "recommended for you" section Error page for the whole product view
Pricing service (dynamic discounts) Show the last cached price (→ 83) with a staleness note Block checkout entirely
Inventory service Show a default "ships in 3–5 days" Fail the whole page load
Review-count service Omit the review count, show the product anyway Fail the whole page load

How it works

  1. For every call to a non-critical dependency, decide in advance — not during the incident — what the feature does when that call fails or the breaker (→ 151) is open.
  2. Pick the fallback per feature: a stale cached value (→ 83, → 85, with its known staleness window), a safe default, or simply hiding that one part of the response.
  3. Distinguish essential from optional dependencies on each page or flow: a page can usually still render without "recommended for you," but checkout cannot proceed without payment — the fallback for an essential dependency may legitimately be "fail clearly," not "pretend to succeed."
  4. Surface degraded state honestly where it matters (a "prices may be out of date" note) rather than silently showing wrong data as if it were current.
  5. Test the degraded path deliberately (chaos or fault-injection testing, full depth → 200) — a fallback that was never exercised often turns out to be broken exactly when it's needed.

Practical example

(illustrative). A product page calls four services. When Recommendations times out, the page renders without that section — the user never notices. When Pricing times out, the page shows the last price cached ten minutes ago with a small "price may have changed" note rather than blocking the page. When Payment (essential, not optional) times out at checkout, the fallback is an honest "payment is temporarily unavailable, please retry" — not a fake success.

When to use it

  • Use when: a feature is optional to the page or flow's core purpose, and a reduced version is genuinely better than an error.
  • Avoid when: the dependency is essential to correctness (charging money, confirming an order) — a fabricated fallback there is worse than a clear failure; fail clearly instead and let the resilience patterns (→ 151, → 152, → 153) limit the blast radius.
  • Failure scenarios: a fallback that was designed but never tested fails in a new way exactly during the real incident; degrading silently (showing stale or default data with no indication) erodes trust once users notice; degrading an essential dependency "gracefully" into a wrong answer (e.g., showing a stale price as current and charging it) turns a visible outage into a silent correctness bug.
  • Simpler alternative: for a feature with no sensible reduced version and low traffic, a plain error with a retry button is simpler than building and testing a fallback path that's rarely exercised.

Practice

(Pattern kind — implement minimal; 20 min, two small processes, shared lab: Redis). Build a product-page handler that calls a "recommendations" dependency and a "pricing" dependency (fake processes you can make fail on command). Implement: recommendations failure → omit that section; pricing failure → serve the last cached price (stored in Redis with a TTL) with a stale: true flag in the response. Make both dependencies fail and confirm the page still returns 200 with both fallbacks visible in the response.

Done when the page never errors out for either dependency's failure, and the stale-price response is honestly flagged, not presented as current.

Shared lab setup

Key takeaway

Decide the reduced behavior for every optional dependency before the incident, and reserve honest failure for dependencies that are actually essential. Done when you can: classify a page's dependencies as essential or optional and design a tested fallback for each optional one. Used next in → 200 (chaos testing exercises exactly these fallback paths).

References

A pattern language for microservices — see references.md.

Exercise: Design a checkout path across four services with explicit timeout budgets, retry policies, breaker thresholds, and the degraded mode for each dependency — then show how a retry storm would start if the jitter were removed.

Source directory

Search the guide