Circuit Breaker Pattern
Learn Circuit Breaker Pattern (Core Microservices Patterns, Microservices Design Patterns) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
The Problem If Service A calls a struggling Service B repeatedly, and each call takes 30 seconds to time out, Service A's own threads/resources get tied up waiting - and if many callers do this, the failure cascades across the whole system, even though only one service was actually unhealthy. What is a Circuit Breaker? Just like an electrical circuit breaker trips to stop current flow when there's a fault, a software Circuit Breaker "trips" to stop calls to a failing dependency, failing fast instead of waiting on a doomed call and giving the failing service room to recover.