Circuit Breaker stops calling a failing service to prevent cascading failures. Like an electrical circuit breaker—if a service fails repeatedly, "trip" the circuit and return cached/default response instead of waiting for timeouts. After cooldown period, try again. States: Closed (working), Open (failing, don't call), Half-Open (testing if recovered). Prevents one failing service from taking down entire system.
Use circuit breakers in microservices when calling external services (payment APIs, email services) that might fail, when one slow service could cascade and take down your app, or when you want graceful degradation (show cached data if real-time fails). Essential for resilient systems. Implement with libraries like Hystrix, resilience4j, or cloud services.
System Design Patterns
Prevent cascading failures