MicroservicePatterns.com
Resilience

Circuit Breaker Lab

Send traffic through a client to a dependency you control. Break it, slow it down, overload it, then watch how the breaker and the retry settings decide whether the rest of your system survives.

Background: Circuit Breaker, Retry with Backoff, Bulkhead.

Breaker closed
Your serviceCLIENTBreakerCLOSED0 / 5 failuresDependencyHEALTHY
–Requests succeeding (last 10 s)
–Average response time
0Calls to dependency per s (capacity 30)
0Calls failed fast per s
Call succeededCall failed or timed outRejected by open breakerHalf-open (probing)
Breaker events
  1. No events yet. Crash the dependency to see the breaker react.
Guided experiments

Run these in order

  1. Watch an outage with no protection

    Load the setup. Every request and every retry still hits the dead dependency. Watch the load counter: it is several times your traffic.

  2. Switch the breaker on

    Tick “Breaker enabled”. After 5 failures in a row the bar turns red. Calls now fail in a few milliseconds and the dependency stops receiving traffic.

  3. Heal it and watch recovery

    Click “Heal dependency”. When the open time ends the breaker goes amber, lets one probe through, and closes on success. Try a longer open time and see how recovery slows.

  4. Compare a hang with a crash

    Load the hanging dependency. Each call burns the whole timeout, so average response time climbs. Turn the breaker on and compare. Then lower the timeout.

  5. Trigger a retry storm

    Load the storm. Retries push load above capacity, which causes more failures and more retries. Then tick jitter, reduce retries, or enable the breaker, one at a time.

  6. See what a breaker will not catch

    Load the flaky setup. At 40% random errors the breaker only trips when five failures happen in a row by chance (about 1% of calls), so it opens at odd moments and says little about the real error rate. Raise retries from 0 to 3 and compare the success rate. Then lower the threshold to 2 and see how often it trips.

This lab simplifies reality on purpose. It models one dependency, trips the breaker on consecutive failures, lets a single probe through when half-open, and retries with exponential backoff. Real breakers often trip on a failure rate over a sliding window, and libraries such as Resilience4j, Polly and Envoy expose those options.