Resilience Patterns · Core Resilience Patterns
Graceful Degradation and Fallbacks
Keep the core experience working when parts fail.
Design each feature's fallback before you need it: cached or stale data, defaults, simpler algorithms, hiding optional sections, read-only mode, or queuing writes for later. Use feature flags as kill switches to turn off expensive features under load. Fallbacks must be cheap and tested — a fallback that calls another fragile service is not a fallback.
Degradation plan examples
| Feature | Normal | Degraded mode |
|---|---|---|
| Recommendations | Personalized ML service | Cached popular items |
| Product price | Live pricing service | Cached price (< 5 min) + recheck at checkout |
| Search | Full-text + facets | Basic search without facets |
| Reviews | Live reviews | Hidden section |
| Writes during DB failover | Synchronous | Accept into queue; process later |
TypeScript
export async function productPage(id: string) {
const product = await products.get(id); // critical
const [reviews, recs] = await Promise.allSettled([
withTimeout(reviewsClient.top(id), 200),
flags.enabled("recommendations") ? withTimeout(recsClient.similar(id), 250) : Promise.resolve(null),
]);
return {
product,
reviews: reviews.status === "fulfilled" ? reviews.value : null, // hide on failure
recommendations: recs.status === "fulfilled" && recs.value ? recs.value : await popular.cached(),
degraded: reviews.status === "rejected" || recs.status === "rejected",
};
}
Common pitfalls
- Fallbacks never exercised until an incident.
- Fallbacks hiding outages from monitoring (emit metrics).
- Degrading critical correctness (stale prices charged without recheck).
Key points
- Plan fallbacks per feature
- Kill switches via flags
- Test and monitor degraded modes
Further reading: AWS Builders' Library: Avoiding fallback in distributed systems
Practice questions
Why does AWS caution against some fallback strategies?
Answer
Fallbacks that are rarely exercised can be buggy, add load or behave unpredictably during incidents; prefer making the primary path more reliable or using simple, regularly-tested fallbacks.
How do feature flags help during overload?
Answer
They let operators instantly disable expensive non-critical features (recommendations, heavy widgets) to free capacity for core flows.
Open in the app to mark lessons complete, take notes and track your progress.