Video in progress
We had this incident in prod. How do you analyze the root cause, and what systemic changes do you propose?
14:02 loyalty-service DB slowed down (p99 50 ms -> 8 s)
14:04 order-service: Tomcat threads 200/200 busy
14:05 gateway: /checkout, /cart, /orders all 504
14:06 order-service liveness probe fail -> k8s started restarting pods
14:15 loyalty DB recovered, but order-service did not stabilize for 25 minutes
This is a cascading failure: a slow dependency was called without a timeout, the threads ran out and it spread up the chain. The fix is timeouts, bulkheads, a circuit breaker, separating health checks from dependencies, and shortening the synchronous chain.
📖 Answer
In a postmortem I focus not on "what broke" but on "why did a small problem stop everything". Loyalty is an optional feature (points), and it should not have stopped checkout.
I go through the chain step by step:
- No timeout, or a very large one.
order-servicecalled loyalty with a 30 s default. Every request held a thread for 8+ s. 200 threads / 8 s = 25 requests per second, far below the traffic. - No isolation. The loyalty calls occupied the shared thread pool, so
/orders, which has nothing to do with loyalty, stopped too. - A misconfigured liveness probe. Because the threads were busy,
/actuator/healthdidn't respond and k8s killed the pods. A restart means a cold JVM, empty caches, and more load. That is why recovery dragged on for 25 minutes. - Retries (if there were any) pushed the load up even more.
What I would propose changing (starting with the biggest impact):
- a 300 ms timeout and a circuit breaker on the loyalty call; the fallback is "points will be calculated later" (calculating points through an async event is even better);
- a semaphore bulkhead: no more than 20 concurrent calls to loyalty;
- the liveness probe checks only that the JVM is alive, not dependencies; readiness is separate;
- an inventory of the optional calls on the checkout path: each one must pass the question "what happens if it fails?";
- an alert for the loyalty DB, and a dependency latency dashboard on the order side.
The main lesson: a checklist (a PR template or platform defaults) that makes a timeout, fallback and bulkhead mandatory when adding a new synchronous dependency. Fixing a single service doesn't stop the next incident, changing the defaults does.
Sign up to mark studied questions and save your progress.