The Unavailable Service
Recommendations are a small widget at the bottom of the page. Why did the entire homepage go down with them?
Ce défi n'est pas encore traduit en Français. Vous lisez la version anglaise.
Mission:With recommendations down, keep the homepage fast and error-free, and stop hammering the failing service so it can recover.
Fernway's homepage service calls the recommendations service on every request. Tonight recommendations is overloaded: each call takes 600 ms or more, and requests pile up until it barely answers at all. The homepage waits, its 120 threads fill up, and the site is down — over a non-critical feature.
Mission: With recommendations down, keep the homepage fast and error-free, and stop hammering the failing service so it can recover.
Objectifs d'apprentissage
- Identify critical vs non-critical dependencies.
- Combine timeouts, circuit breakers and fallbacks.
- Give a failing dependency room to recover.
SimulationSimulé
@CircuitBreaker(name = "recommendations", fallbackMethod = "popularProducts")@TimeLimiter(name = "recommendations") // timeout-duration: 200mspublic CompletableFuture<List<Product>> recommendations(long userId) { return CompletableFuture.supplyAsync(() -> recoClient.forUser(userId));}CompletableFuture<List<Product>> popularProducts(long userId, Throwable t) { return CompletableFuture.completedFuture(popularCache.top(12)); // non-personalised, but the page renders}// resilience4j.circuitbreaker.instances.recommendations: failure-rate-threshold 50, wait-duration-in-open-state 30s