Circuit Breaker

Also known as: circuit breaker pattern.

A guard that stops calling a failing service after repeated errors, waits, then tests carefully before resuming.

Synthetic dataExamples on this page use synthetic data created for illustration.

Definition

A circuit breaker watches calls to a dependency and, after repeated failures, opens: further calls are stopped immediately instead of attempted. After a pause it lets a few trial calls through and closes again only if they succeed, which protects both the caller and the struggling service.

In plain terms

The breaker has three states. Closed: calls go through and failures are counted. Open: calls are refused at once, without waiting for a timeout. Half-open: after a cool-down, a trial call is allowed; success closes the breaker, failure opens it again.

In data collection the same idea has a second meaning. If a source starts refusing or blocking requests, the right response is to stop, alert a person, and record the gap honestly, not to push harder or fill the gap with guesses. Stopping is the feature.

Example

Rule: open after 3 failures in a row, stay open for 10 minutes.

TimeEventState afterwards
10:00Call failsClosed (1 failure)
10:05Call failsClosed (2 failures)
10:10Call failsOpen (3 failures)
10:15Call refused immediatelyOpen
10:20One trial call succeedsClosed again

The collection log should show the 10:10–10:20 gap as missing data, not as zeros.

Common misunderstandings

  • “The breaker fixes the failure.” It only limits the damage and gives the problem time to clear.
  • “An open breaker is an error in the system.” It is the system working as designed.
  • “It should always resume by itself.” When the cause is a block or a change in access conditions, a person should look before collection restarts.

References

  1. Martin Fowler. CircuitBreaker . martinfowler.com, 2014.
  2. Michael T. Nygard. Release It!: Design and Deploy Production-Ready Software . Pragmatic Bookshelf, 2018. ISBN 978-1680502398.