Development

Circuit Breaker

AI-assisted editorial review:

A circuit breaker is a resilience pattern that temporarily rejects calls to a failing dependency once a configured threshold is reached, helping contain cascading failures. In his 2014 explanation, Martin Fowler describes wrapping a protected operation, observing failures, and rejecting subsequent attempts without making the remote call. Common implementations use closed, open, and half-open states; half-open permits trial calls to assess recovery. Michael Nygard helped popularize the pattern in Release It! [1]

What does Circuit Breaker mean in simple terms?

Imagine an electrical breaker isolating a faulty circuit. If an external service stops responding, repeated requests can tie up your server’s resources. A software circuit breaker stops sending those requests for a while and returns an error or a designed fallback quickly. This helps the rest of the application keep working, but does not repair the failing service or guarantee that every feature remains available.

How can Circuit Breaker be explained with an analogy?

Like a breaker on a household electrical panel, it disconnects one troubled circuit to help protect the rest of the system.

Where is Circuit Breaker used?

Case 1

Netflix — Hystrix

Hystrix combined dependency isolation with a circuit breaker. Its documented defaults include a minimum request volume of 20 within the rolling window, an error threshold of 50%, and a 5-second sleep window before trial requests. These are implementation defaults, not recommended settings for every application. [4] The historical project wiki reports more than 10 billion Hystrix command executions per day using thread isolation at the Netflix API; this is a reported workload, not a measured improvement attributable to the breaker. [3]

Case 2

Woowa Brothers — Shared-platform integration

A January 2024 engineering article describes moving search, advertising, and coupon functions to shared platforms and using Resilience4j to address failure propagation through synchronous dependencies. It discusses monitoring through Prometheus and Grafana. The article’s illustrative configuration uses a count-based window of 10 calls, a 50% failure threshold, and a 10-second open-state wait. These are published example settings, not an adoption-effect measurement or a verified production configuration. [6]

Case 3

Hwahae — Python implementation with Redis state

Hwahae’s August 2024 article describes implementing a breaker for its Python environment and sharing state through Redis across instances. Its host-level configuration example uses an 80% failure threshold, a minimum of 900 calls, and a 300-second time window. In a local API load test averaging 150 TPS, Redis CPU usage remained below 4%; this result is specific to that test. The team also reports the breaker and fallback operating during an ML-serving API outage. [7]

Case 4

LINE — Circuit breakers in Armeria

LINE’s July 2016 article explains how circuit breakers can be added with decorators starting with Armeria 0.13.0. It describes failure-rate thresholds, minimum request counts, and sliding windows. It also allows grouping by host, method, or both: an overly broad breaker can block healthy operations along with a failing one. Version availability and configurable options describe implementation capabilities, not quantified reliability gains. [8]

Learning steps, limitations and developments

Try it today
1. Choose one slow or failure-prone external dependency.
2. Review the past month’s failure rate and response-time distribution.
3. Set the failure threshold and minimum call count for your traffic. Define which errors count as dependency failures.
4. Decide the fallback before enabling the breaker: a clear error, stale data where acceptable, or another safe response.
5. Export state changes and relevant request metrics to a dashboard; test opening, trial calls, recovery, and fallback behavior.

Limits and evolution
A circuit breaker has tradeoffs. The AWS Builders’ Library article explains that state-dependent behavior can be difficult to test and may delay recovery. It describes using local token buckets to limit retries instead of relying on a breaker for that problem. [9] Hystrix is in maintenance mode, with 1.5.18 identified as its final release; its repository recommends considering active alternatives for new projects. [10]

Do not copy another team’s thresholds blindly. Woowa Brothers’ example uses a 10-call window and a 50% failure threshold, while Hwahae’s host-level example requires at least 900 calls in a 300-second window and uses an 80% threshold. Window size and minimum call count are different settings. [6][7] With little traffic, a failure percentage can fluctuate sharply, so set an appropriate minimum sample size. A circuit breaker does not itself limit concurrent calls; combine it with timeouts or a bulkhead when needed. [5][8]

Which sources explain Circuit Breaker?

  1. Martin Fowler — Circuit Breaker (6 March 2014) — https://martinfowler.com/bliki/CircuitBreaker.html
  2. Michael Nygard — Release It! Second Edition — https://pragprog.com/titles/mnee2/release-it-second-edition/
  3. Netflix — Hystrix: How it Works — https://github.com/Netflix/Hystrix/wiki/How-it-Works
  4. Netflix — Hystrix: Configuration — https://github.com/Netflix/Hystrix/wiki/Configuration
  5. Resilience4j — CircuitBreaker — https://resilience4j.readme.io/docs/circuitbreaker
  6. Woowa Brothers — Circuit breaker implementation (11 January 2024) — https://techblog.woowahan.com/15694/
  7. Hwahae — Circuit breakers for internal communication (29 August 2024) — https://blog.hwahae.co.kr/all/tech/14541
  8. LINE Engineering — Circuit breakers for distributed services (24 July 2016) — https://engineering.linecorp.com/en/blog/circuit-breakers-for-distributed-services/
  9. AWS Builders’ Library — Timeouts, retries, and backoff with jitter — https://aws.amazon.com/builders-library/timeouts-retries-and-backoff-with-jitter/
  10. Netflix — Hystrix project status — https://github.com/Netflix/Hystrix