GRACEFUL DEGRADATION

Serve less, but keep serving

L112 MINRELIABILITY
PREDICT

Catalog, pricing, reviews and recommendations are each up 99% of the time, independently. The product page calls all four and returns 500 if any one fails. How often does it render?

A page that fans out to N dependencies and needs all of them is only as available as their product. Four dependencies at 99% give you a page at 96%. Graceful degradation splits them: critical dependencies (the page is wrong without them) fail the page, and optional ones fall back to a cached copy, a default, or nothing. Each optional call also gets a short time budget, so a hanging widget cannot hold the page hostage. The page serves less, but it serves.

▶ SIMULATION
CATALOG · critical
health: up
responds in 40 ms
last request: —
PRICING · critical
health: up
responds in 30 ms
last request: —
PRODUCT PAGE
fallbacks: off
request #—: no request yet
t = 0 ms
REVIEWS · optional
health: up
responds in 60 ms
last request: —
RECOMMENDATIONS · optional
health: up
responds in 80 ms
last request: —
AVAILABILITY
rendered 0 / 0 requests (100%)
while catalog + pricing up: 0 / 0 (100%)
pages lost to optional widgets: 0
✓ the page renders whenever catalog + pricing are up✓ no page without catalog + pricing
SCHEDULE
01[PAGE]request #1: render product page
02[REVIEWS]reviews returns errors (fails in 30 ms)
03[PAGE]request #2: render product page
04[PAGE]request #3: render product page
05[REVIEWS]reviews recovers
06[RECOMMENDATIONS]recommendations stops answering (times out after 1000 ms)
07[PAGE]request #4: render product page
08[RECOMMENDATIONS]recommendations recovers
09[PAGE]request #5: render product page
Start of no degradation scenario. 9 steps.
// every widget is on the critical path
const [catalog, pricing, reviews, recs] = await Promise.all([
  fetchCatalog(id), fetchPricing(id), fetchReviews(id), fetchRecs(id),
]);
return render({ catalog, pricing, reviews, recs });

Watch the page renders whenever catalog + pricing are up. In NO DEGRADATION it turns red the first time reviews fails. In FIX: FALLBACKS the same outages produce the same pages, and the last step shows the page still erroring, correctly, when catalog goes down.

INJECT A FAULT NOT YET

Five requests, every dependency healthy, no fallbacks. Take down one dependency somewhere in the run so that the page fails while catalog and pricing are still up.

GOAL: a request fails while catalog + pricing are up

FIX IT NOT YET

Rewrite renderPage so that reviews and recommendations degrade when their fetcher throws (a cached copy, a default, or leaving the widget out with null or no key), while catalog and pricing still fail the page. The grader fails each dependency in turn.

Mental model:

Every dependency on a page is a vote on whether the page renders. Decide which votes count. Critical dependencies fail the page because a page without them is a lie. Optional ones get a fallback and a short budget, and the page does not wait for them to be sure. If you cannot say which group a dependency belongs to, it is critical by accident, and it will take you down.

IN PRODUCTION

Any aggregated page or API: product pages, home feeds, dashboards, search results with ads and personalisation, mobile BFFs. The symptom is a core flow failing because of a service nobody considers core.

IN INTERVIEWS

“A page depends on six services. How do you keep it up when one of them is down?” Separate critical from optional, name a fallback per optional widget (cache, default, hide), give each optional call a time budget, and say out loud that a critical failure should still error rather than render a wrong page.

RECALL CARDS Tap to flip. They join your review deck when you mark the lesson complete.

USED IN

Chapters that build on this lesson.

NEXT: RATE LIMITING →