What are Graceful Degradation and Fallbacks?
Topic: microservices, Resilience. Level: Intermediate.
Answer
Graceful degradation keeps the core experience working when a non-critical dependency fails, by returning a reduced-but-useful response instead of an error. Examples: show cached/popular recommendations when the recs engine is down, hide the reviews section if the reviews service fails, or accept an order and settle payment later. A **fallback** is the concrete alternative value/action invoked on failure (via circuit breaker/try-recover). Distinguish critical paths (must succeed) from optional ones (safe to degrade).
```java
ProductPage page = new ProductPage();
page.setProduct(catalog.get(id)); // critical — must succeed
page.setReviews(Try.ofSupplier(() -> reviews.get(id)) // optional — degrade
.recover(ex -> List.of()).get());
page.setRecommendations(Try.ofSupplier(() -> recs.get(id))
.recover(ex -> cache.popular()).get());
return page; // page renders even if reviews/recs are down
```