GRACEFUL DEGRADATION
Serve less, but keep serving
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.
// 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 });// critical: fail the page. optional: fall back, with a short budget.
// Start all four at once, so the page waits for the slowest, not the sum.
const reviewsP = withFallback(fetchReviews(id), cache.get(`reviews:${id}`) ?? [], 200);
const recsP = withFallback(fetchRecs(id), [], 200);
const [catalog, pricing] = await Promise.all([fetchCatalog(id), fetchPricing(id)]);
const [reviews, recs] = await Promise.all([reviewsP, recsP]); // never reject
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.
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
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.
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.
“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.
USED IN
Chapters that build on this lesson.
- Launches and go-to-marketProduct Manager
- Testing in production and observabilityQA and Quality Engineering
- Capacity and costSRE, Platform and DevOps
- Reliability and infrastructure strategySRE, Platform and DevOps
- Leading a sev-1 as the technical leadStaff and Principal Engineer