Search⌘ K
AI Features

Circuit Breaker Pattern

Explore the Circuit Breaker pattern to understand how it prevents cascading failures by monitoring downstream dependencies. Learn its three states—Closed, Open, and Half-Open—and how to configure thresholds and timeouts. Discover how to implement, monitor, and tune circuit breakers to maintain system resilience and enhance availability in distributed architectures.

A single slow database query is all it takes for one downstream dependency to start responding in 30 seconds instead of 300 milliseconds, and the calling service’s thread pool fills up. Requests queue behind the stalled threads, latency spikes propagate upstream, and within minutes, an entire microservices fleet is degraded. This cascading failure pattern is one of the most common production incidents in distributed systems. Circuit breakers are frequently deployed inside sidecar proxies like Envoy, exactly the deployment vehicle discussed in the previous lesson on the Sidecar pattern.

The Circuit Breaker pattern addresses this failure mode directly. Borrowed from electrical engineering, where a physical breaker trips to prevent a short circuit from burning down a building, the software circuit breaker prevents a system from repeatedly calling a failing dependency. This lesson covers the pattern’s states and transitions, walks through a programmatic implementation, and examines how to monitor and tune circuit breakers in production environments.

The three states of a circuit breaker

The Circuit Breaker pattern operates as a stateful proxyA wrapper around outbound calls that maintains internal state (such as failure counts and current mode) to decide whether requests should be forwarded or blocked.. This proxy monitors calls to a downstream dependency and short-circuits requests when failures exceed a configured threshold. ...

The breaker moves from closed to open when the failure count or failure rate crosses a configured threshold within a defined time window.
1 / 4
The breaker moves from closed to open when the failure count or failure rate crosses a configured threshold within a defined time window.

Three distinct states govern the breaker’s behavior: ...