A circuit breaker is a small state machine with three states. Closed is normal: calls pass through and the breaker counts failures. If the failure rate crosses a threshold (for example, more than 50 percent of the last 20 calls failed, or 5 consecutive failures), the breaker flips to Open.
In the Open state, no calls go through at all. Every request returns immediately with an error or a fallback, without ever touching the network. The breaker starts a timer, often 10 to 60 seconds. This is the cooldown that lets the downstream service stop being hammered and recover.
When the timer expires, the breaker moves to Half-Open. Here it lets a small number of trial requests through. If they succeed, the dependency looks healthy again, so the breaker resets to Closed. If they fail, it snaps back to Open and waits another cooldown. This trial step is what keeps the breaker from flooding a still-fragile service the instant the timer ends.
Most real implementations track failures over a rolling time window rather than a simple count, and they treat timeouts and slow responses as failures, not just thrown exceptions. They also expose metrics so you can see the breaker tripping in your dashboards.