Free — no signup required

Circuit Breaker States

2 min read

The Three States of a Breaker

A circuit breaker is implemented as a state machine with three states. Understanding the transitions between states is essential for configuring one correctly.

1. CLOSED (Normal operation)
The circuit is closed, meaning requests flow normally to the remote service. The breaker runs silently in the background, counting successes and failures within a rolling time window. As long as the failure rate stays below the configured threshold, the breaker stays CLOSED. This is the default, healthy state.

2. OPEN (Fail fast)
The failure threshold was exceeded. The breaker trips to OPEN. All subsequent requests fail immediately — no network call is made. A configurable timer starts (e.g., 30 seconds). During this time, the downstream service has a chance to recover without being bombarded by traffic. Callers receive an immediate error and should execute their fallback logic.

3. HALF-OPEN (The probe)
When the OPEN timer expires, the breaker moves to HALF-OPEN. It is not yet confident the service has recovered, so it allows a small, controlled number of "probe" requests through — for example, 5 requests.
- If the probes succeed: The service has recovered. The breaker transitions back to CLOSED and normal traffic resumes.
- If the probes fail: The service is still unhealthy. The breaker transitions back to OPEN and restarts the timer.

Key Point: The HALF-OPEN state is where circuit breaker configuration gets subtle. If you allow too many probe requests, you risk overwhelming a service that is only partially recovered. If you allow too few, you may be slow to detect recovery. Production circuit breakers often use a percentage-based probe strategy (e.g., "allow 10% of normal traffic through") rather than a fixed count, which scales better under varying load.

This is one of 18 chapters

Every chapter is free — Kubernetes, Terraform, SRE, distributed systems, and more — with fast daily review built in.

Sign up free