All lessons · Guided routes

Simulator · Service mesh

Retries, timeouts, and circuit breakers

A booking goes gateway → orders → pricing → inventory. Each service retries failed calls. Make inventory fail, and see what retries, timeouts, and a circuit breaker do to it.

At Quillfern Parcels. This is the system from chapter 6 of the Quillfern story, "Splitting the booking flow": Booking a delivery now calls orders, pricing, and inventory services. When inventory slows down, retries at every layer flood it and the whole booking flow falls over.

What the model simplifies

Only the deepest service, inventory, fails, independently on each attempt. Every caller retries a failed call the same number of times, with no back-off delay. The circuit breaker sits in pricing, in front of inventory, and opens when inventory fails half its calls or more. Inventory can handle 1,500 calls a second. Real failures are correlated, which makes retries worse than this model shows. Every number on this page comes from one shared set of calculations, which the simulation questions use too, so a question can never disagree with what the simulator shows.

The drills, written out

A retry storm
  1. Healthy state. Inventory fails 1% of calls; with two retries at each service 100.00% of bookings succeed, and inventory sees 808 calls a second.
  2. Trigger. A slow disk makes inventory fail 60% of its calls.
  3. What is affected. Every service above it, because each one retries what failed below it.
  4. Symptoms. Bookings slow down sharply; inventory's dashboards show far more traffic than there are customers.
  5. Metrics. Inventory now receives 2.50 calls per booking, 2,000 a second against a capacity of 1,500. In this model the retries still get 100.00% of bookings through, but only by sending inventory more work than it can do. In reality the overload pushes its failure rate higher, and then the retries fail too.
  6. Logs. Each layer logs its own retries of the same booking.
    pricing  WARN  inventory call failed (try 1 of 3): 503
    pricing  WARN  inventory call failed (try 2 of 3): 503
    orders   WARN  pricing call failed (try 1 of 3): 503
  7. Reasoning. Retries at every layer multiply: with 2 retries at 3 layers, one booking can cause up to 27 calls. The extra load makes inventory fail more, which causes more retries.
  8. Mitigation. Turn on a circuit breaker in pricing and retry once, at one layer. With inventory failing more than half its calls, the breaker opens and stops calling it.
  9. Recovery. Inventory's load drops to 0 calls a second, so it can recover; orders shows "stock check delayed" and accepts the booking. The breaker lets a few test calls through and closes when they succeed.
  10. Prevention. Retry at one layer only, with back-off and jitter and a retry budget; give inner calls shorter timeouts than outer ones; and design a fallback for each dependency.

Learn it properly

All simulators · Curriculum map