Skip to content

Circuit Breaker Step-Through

Run the Circuit Breaker Step-Through MicroSim Fullscreen

About This MicroSim

A circuit breaker stops calling a vendor for a while after it has failed several times in a row. It has three states.

  • Closed: calls go through. Each failure adds 1 to the count; a success resets it to 0. At 5 failures in a row the breaker opens.
  • Open: every call is skipped and returns not checked at once, until 30 seconds have passed.
  • Half-open: the next call goes through as a trial. Success closes the breaker. Failure opens it again for another 30 seconds.

This MicroSim steps through a synthetic outage. The vendor is down from 0:00 to 1:10 and healthy after that. Nine calls arrive. At six checkpoints the sim stops and asks you to predict what happens next.

How to Use

  1. Press Step to move to the next event.
  2. At a checkpoint, pick the breaker state after the event. If a call arrives, also pick its result.
  3. Press Check prediction to see the answer and the rule that applied.
  4. Watch the tally of calls that waited out a timeout and calls answered at once.
  5. Hover over the states, the status rows and the event log to read more.
  6. Press Start over to try again.

Iframe Embed Code

You can add this MicroSim to any web page by adding this to your HTML:

<iframe src="https://arunbatchu.github.io/good-enough-engineering/sims/circuit-breaker-step-through/main.html"
        height="586px"
        width="100%"
        scrolling="no"></iframe>

Lesson Plan

Learning Objective

Use the three-state circuit breaker rules to predict the breaker's state and each scan's photo-check result across a sequence of calls during a vendor outage and recovery.

Grade Level

Adult professional (Good Enough Engineering)

Duration

10-15 minutes

Prerequisites

Vendor outage, circuit breaker and its closed, open and half-open states, and the not checked result.

Activities

  1. Predict (5 min): Before stepping, write down when you expect the breaker to open and close.
  2. Apply (5 min): Step through all nine events, predicting at each checkpoint.
  3. Discuss (5 min): Only 6 of the 9 calls waited out a timeout. What would members have seen without the breaker?

Assessment

Mastery is 5 or more of the 6 checkpoints predicted correctly on the first attempt.

References

  1. Chapter 9: Working With Outside Services - the section on circuit breakers.
  2. Michael T. Nygard, Release It! Design and Deploy Production-Ready Software, Pragmatic Bookshelf, 2007.
  3. CircuitBreaker - Martin Fowler, 2014.
  4. p5.js reference - p5.js documentation.