Circuit Breaker Pattern
Subject: Computer and Technology noun /ˈsɜːr.kɪt ˈbreɪ.kər ˈpæt.ərn/ 1 definition
- distributed-systems
- software-architecture
- fault-tolerance
- design-patterns
-
Definition (noun)
Entry #73 · UpdatedThe Circuit Breaker Pattern is a fault-tolerance design pattern that wraps calls to external services or fragile resources in a stateful proxy that monitors for failures and timeouts. When errors exceed a configured threshold, the breaker trips from a closed state into an open state, failing subsequent requests immediately rather than waiting on an unresponsive dependency or compounding load through repeated retries. After a cooldown period, it transitions to a half-open state to allow a limited number of probe requests, restoring normal traffic if they succeed or tripping open again if they fail—preventing resource exhaustion and cascading outages across distributed systems.
Common Forms
Count-Based Circuit Breaker: Evaluates a sliding window of recent calls (such as the last 100 requests) and trips open once the failure count or percentage crosses a threshold, keeping behavior predictable under uneven traffic.
Time-Based Circuit Breaker: Aggregates call outcomes over a rolling time interval—such as the last 30 seconds—and opens when failures exceed a target rate, ensuring older errors expire naturally.
Slow-Call (Latency-Based) Circuit Breaker: Trips not only on explicit errors or timeouts, but also when responses consistently exceed a latency threshold, preventing thread-pool starvation during partial service brownouts.
Proxy-Level (Service Mesh) Circuit Breaker: Enforces connection caps, pending-request limits, and outlier detection inside a network proxy or API gateway (such as Envoy), isolating unhealthy upstream instances without modifying application code.
Example
When a downstream payment gateway begins timing out after 3 seconds on more than 50% of calls across a 20-request window, an e-commerce checkout service's circuit breaker trips to the open state and immediately fails new payment requests for 30 seconds while returning a cached "retry shortly" notice. Once the 30-second cooldown expires, the breaker enters the half-open state, lets three probe requests through, and returns to the closed state after all three receive
200 OKresponses.