The Real Fullstack

The Unavailable Service

Recommendations are a small widget at the bottom of the page. Why did the entire homepage go down with them?

Engenheiro9 minSimulador de fluxoLaboratório de performance
resilience4jspring-bootkuberneteshttp

Este desafio ainda não foi traduzido para Português (Brasil). Você está lendo a versão em inglês.

Missão:With recommendations down, keep the homepage fast and error-free, and stop hammering the failing service so it can recover.Contexto · Objetivos de aprendizagem ▾

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.

Missão: With recommendations down, keep the homepage fast and error-free, and stop hammering the failing service so it can recover.

Objetivos de aprendizagem

  • Identify critical vs non-critical dependencies.
  • Combine timeouts, circuit breakers and fallbacks.
  • Give a failing dependency room to recover.
Simulação
Simulado
VisitorsHomepageRecommendations
Executar simulação
@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

Simplificação

Steady-state queueing; an open breaker sends 5% of calls as probes. Modelo educacional — os números ilustram comportamento, não são benchmarks.

Conceitos

Desafios relacionados

Referências