Intermediate · INTERACTIVE LESSON
Circuit breaker
Watch failures open a circuit, requests fail fast, and a single probe test service recovery.
The interactive player is loading. If it does not appear, you can still read the explanation below.
THE IDEA BEHIND THE STEPS
How it works
A circuit breaker protects calls to a failing dependency. This lesson uses one shared breaker for all clients, with a consecutive-failure policy. Closed permits calls: each success resets the failure counter, and reaching the failure threshold opens the circuit.
Open rejects new requests immediately without calling the service. After cooldown, the next request becomes a single half-open probe. Other arrivals fail fast while it runs. A successful probe closes the circuit; a failed probe opens it again and restarts cooldown. Cooldown expiry alone does not prove the service is healthy.
Clients receive request IDs in round-robin order. Sequential mode waits for the result and then the interval before sending the next request. Concurrent mode sends bursts at fixed intervals; burst size is the total across clients. Already admitted calls complete even if the circuit opens. Their old-generation results still return to the caller but cannot change a newer circuit state. Completions are handled before arrivals at the same time, in request-ID order.
The service fails before the configured recovery time and succeeds at or after it, evaluated when processing completes. Animated network hops take no simulated time. This deterministic model omits retries, fallback, queues, distributed state and real capacity constraints. Production breakers may use rolling failure rates and other probe policies. The circuit breaker does not repair the service or retry a failed operation.