11 / 25 · Service boundaries
Circuit breaker
A circuit breaker temporarily stops calls to a dependency that appears unhealthy, then cautiously tests recovery. It prevents repeated waiting and extra pressure; it does not repair the dependency.
What you will practise
- Follow closed/open/half-open
- bound recovery probes
- separate breaker and retry
Before you start: Dependency, timeout and failure measurement.
About 4 minutes · offline-generated English female narration · captions included. Diagrams are conceptual; timings are illustrative.
Download MP4CaptionsListen without the video
Download audioChapters and full transcript
Let us understand circuit breaker. A home fuse interrupts an unsafe circuit instead of letting every appliance keep drawing current. A software breaker is not the same physical mechanism, but the useful idea is similar: stop repeated harmful attempts, observe conditions and restore access carefully. A circuit breaker temporarily stops calls to a dependency that appears unhealthy, then cautiously tests recovery. It prevents repeated waiting and extra pressure; it does not repair the dependency.
Follow the normal path. The breaker allows normal calls and records eligible outcomes. Timeouts still bound each attempt; a closed breaker is not a guarantee of health. The dependency times out repeatedly. A minimum sample and measurement window help distinguish a pattern from a single unlucky request. If SeatSpot recommendations repeatedly time out, continuing to call them can occupy every connection. A breaker can reject or use a safe optional fallback while core booking work continues.
Now change one condition. The breaker opens and rejects dependency calls quickly. This frees local resources and avoids repeating expensive failures while recovery is investigated. A common misunderstanding is this: An open breaker makes every fallback safe. A fallback must preserve business meaning; it cannot fabricate a successful payment. Think about this. The breaker opens. Has it repaired the failed payment provider? Pause the video and make your prediction. No. It stops repeated calls quickly. Recovery probes only test whether the dependency can be used again.
Let us reason with a concrete example. An illustrative breaker opens after enough samples show a 50% eligible-failure rate in its window. A minimum of 20 calls avoids opening after one failure out of one call in this example. The numbers are teaching choices, not recommended universal settings. Define which timeouts/errors count, limit half-open probes and watch false trips alongside recovery time. These figures are teaching examples, not production guarantees.
Turn the idea into a design decision. Optional recommendations can be omitted. Essential payment outcomes must remain pending or failed according to verified state, not invented to hide the outage. After a reset interval, allow a limited probe set. Sending every waiting caller at once can overload a dependency that is only partly recovered. When you try the practice task, look for this result. Few probes avoid a recovery stampede; thresholds are workload choices.
Check your understanding. Successful probes restore normal traffic; failed probes reopen the breaker. Observe both false trips and recovery behavior under controlled failure tests. Here is a challenge. What should a breaker do after the reset interval? Pause before the answer. Move to half-open with bounded probes. Evaluate actual outcomes before restoring full traffic; otherwise recovering capacity may be overwhelmed again. For an interview, define eligible failures, thresholds and bounded probes. Say what you would measure, not only which tool you would buy.
Start with an everyday picture
A home fuse interrupts an unsafe circuit instead of letting every appliance keep drawing current. A software breaker is not the same physical mechanism, but the useful idea is similar: stop repeated harmful attempts, observe conditions and restore access carefully.
Why SeatSpot needs this
If SeatSpot recommendations repeatedly time out, continuing to call them can occupy every connection. A breaker can reject or use a safe optional fallback while core booking work continues.
Trace one step at a time
Move through the diagram at your pace. Teal paths are active; unavailable components are labelled.
Closed: calls flow
The breaker allows normal calls and records eligible outcomes. Timeouts still bound each attempt; a closed breaker is not a guarantee of health.
Read all six mechanism steps
Closed: calls flow
The breaker allows normal calls and records eligible outcomes. Timeouts still bound each attempt; a closed breaker is not a guarantee of health.
Observe repeated failures
The dependency times out repeatedly. A minimum sample and measurement window help distinguish a pattern from a single unlucky request.
Open: stop pressure
The breaker opens and rejects dependency calls quickly. This frees local resources and avoids repeating expensive failures while recovery is investigated.
Choose an honest fallback
Optional recommendations can be omitted. Essential payment outcomes must remain pending or failed according to verified state, not invented to hide the outage.
Half-open: probe
After a reset interval, allow a limited probe set. Sending every waiting caller at once can overload a dependency that is only partly recovered.
Recover or reopen
Successful probes restore normal traffic; failed probes reopen the breaker. Observe both false trips and recovery behavior under controlled failure tests.
Pause and make a prediction
The breaker opens. Has it repaired the failed payment provider?
Correct a common misunderstanding
Claim to question: An open breaker makes every fallback safe.
Better explanation: A fallback must preserve business meaning; it cannot fabricate a successful payment.
Walk the breaker states
- Record eligible failures while the breaker is closed.
- Open after an explicit minimum sample and threshold.
- Permit a small half-open probe set, then decide whether to close or reopen.
Check what you can explain
This is your self-check, not an automated grade. Try again without the diagram tomorrow.
0 of 3 goals checked. Choose one remaining idea to practise next.
Teach it back
Without looking, explain what this component changes, what it does not solve and what happens if it fails. Use the animation to check your explanation, then switch to Engineering.
Engineering model and trade-offs
Closed means normal calls are allowed while failures are measured. Open means calls are rejected quickly for a period. Half-open allows a limited probe set; success can close the breaker and failure can reopen it.
Define eligible failures, a minimum sample, threshold, window and reset policy. A small number of failures at low traffic can mislead a naive ratio. Per-instance breakers can reach different states, which must be understood operationally.
Combine timeouts, concurrency isolation and bounded retries. A breaker protects resources only if requests cannot pile up elsewhere. Fallback must preserve business meaning; do not fabricate a successful charge.
Work through an example
An illustrative breaker opens after enough samples show a 50% eligible-failure rate in its window.
Reason with the numbers
A minimum of 20 calls avoids opening after one failure out of one call in this example. The numbers are teaching choices, not recommended universal settings.
Make a decision
Define which timeouts/errors count, limit half-open probes and watch false trips alongside recovery time.
Implementation sketch
CLOSED: allow calls and record eligible outcomes
OPEN: reject quickly or use a safe fallback
After reset interval -> HALF_OPEN
HALF_OPEN: limited probes; success -> CLOSED
Failed probe -> OPENState-machine sketch only. Production libraries must handle concurrency, cancellation and metric windows correctly.
Where this is used
- Isolating an unhealthy dependency.
- Fast optional fallback during repeated remote failures.
Common mistakes
- Treating an open breaker as proof of root cause.
- Allowing every caller to probe recovery at once.
- Returning fake success for essential writes.
Practise a reasoned answer
Answer aloud or write notes before opening the reference. These prompts teach reasoning and trade-offs; they are not claimed questions from a particular company.
Circuit breaker versus retry?
Choose a practice depth
- Foundation
- Name the three states and their purpose.
- Practical
- Define eligible failures, thresholds and bounded probes.
- Advanced
- Discuss low-traffic bias, per-instance state, false trips and interactions with retries.
Self-check rubric
- State the required user outcome and the relevant invariant.
- Explain the normal path and one failure path.
- Name a cost or consistency/latency trade-off.
- Say what you would measure or test before trusting it.
For deeper practice, connect this topic to the previous lesson and identify a shared bottleneck. A longer answer is not automatically a better answer.
Try it before viewing the solution
What should a breaker do after the reset interval?
Check one key idea
Your explanation and interview notes
Saved only in this browser when storage is available. Export a backup from the course page before clearing browser data or moving devices.
Loading your local notes…
Official references and next reading
The explanation, fictional examples and animations are original teaching material. Vendor behavior depends on the specific product/version; use its documentation before deploying.