ReliabilityBeginner

Explain the states of a circuit breaker

“Walk me through Closed, Open and Half-Open. What triggers each transition, and what should the caller do while the breaker is open?”

What this tests

  • The three states and the transitions with concrete thresholds
  • Why a minimum call count and a window exist
  • What "fail fast" returns to the user
  • Scope: one breaker per dependency, not one global switch

Answers by level

Read the beginner answer first and notice what is missing.

Closed: calls pass; the breaker counts outcomes over a sliding window (last 100 calls or last 60 s). When the failure rate crosses a threshold (say 50%) and a minimum number of calls has been seen (say 20, so two failures out of two do not trip it), it moves to Open. Open: calls are rejected immediately without touching the dependency, for a fixed duration (10–30 s). Then Half-Open: a small number of probe calls (1–5) are allowed; if they succeed, back to Closed and the counters reset; if any fails, back to Open with a fresh timer.

While open, the caller should not simply throw. It returns a fallback: a cached value, a default (an empty recommendations list), or a clear degraded response ("try again shortly") within milliseconds. The point is to protect the caller's threads and give the dependency room to recover — see Circuit Breaker.

Green flags · Red flags

Strong green flag · Mentions jittering the open duration so a fleet's half-open probes do not arrive simultaneously.
Green flags
  • Three states with numeric thresholds and a minimum call count
  • Half-open as a limited probe, not a full reopen
  • Fallback behaviour when open, specific to the feature
  • Per-dependency scope
  • Counts timeouts and slow calls as failures
Red flags
  • "When the breaker opens we retry until it closes."
  • One global breaker for the whole service
  • Trips on the first error with no minimum sample
  • Cannot say what the caller returns while open

Follow-up questions

F1
Why a minimum number of calls before tripping?
F2
The dependency is not erroring but every call takes 6 s. Does the breaker help?
F3
What do you return to a user when the recommendations breaker is open?

Scenario

Your product page calls a recommendations service. Yesterday that service hung for 20 minutes (no errors, 15 s responses) and every product page timed out, although recommendations are a side panel. A breaker library was already in place with a 50% error threshold. Explain why it did not trip and configure it so the page stays up next time.

Learn this topic