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?

工程师9 分钟流程模拟器性能实验室
resilience4jspring-bootkuberneteshttp

此挑战尚未翻译为简体中文,你正在阅读英文版本。

任务: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.

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

学习目标

  • Identify critical vs non-critical dependencies.
  • Combine timeouts, circuit breakers and fallbacks.
  • Give a failing dependency room to recover.
模拟
模拟数据
VisitorsHomepageRecommendations
运行模拟
@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

简化说明

Steady-state queueing; an open breaker sends 5% of calls as probes. 教学模型——数字用于说明行为,并非基准测试。

概念

相关挑战

参考资料