What is the Circuit Breaker pattern?

Answer

The Circuit Breaker pattern prevents a service from repeatedly calling a downstream service that is failing, which would waste resources and potentially cascade the failure. It works like an electrical circuit breaker: in the Closed state, requests pass through normally; if failures exceed a threshold, it trips to the Open state, where all requests immediately fail with a fallback (no network call is made); after a timeout, it enters the Half-Open state where a single test request is sent — if it succeeds, the breaker closes again, otherwise it opens again. Libraries like Resilience4j (Java) and Polly (.NET) provide circuit breaker implementations. Service meshes like Istio can also enforce circuit breaking transparently without library changes.