Circuit Breaker Pattern

What is the Circuit Breaker Pattern?

In distributed systems, services often depend on other services. If one downstream service becomes slow or fails repeatedly, it can cause cascading failures, overwhelming the calling service (client) with long waits or errors. The Circuit Breaker pattern acts like an electrical circuit breaker to prevent this.

It's a proxy for operations that might fail. It monitors failures and, if they exceed a threshold, "opens" the circuit, preventing further calls to the failing service for a set period. This allows the downstream service time to recover and protects the client from making futile, resource-consuming requests.

Circuit Breaker States

This state machine protects the client and gives the downstream service breathing room to recover.

Visualize the Pattern

Configure the breaker, control the service's health, and send requests to see the state transitions.

Client App

Circuit Breaker

CLOSED
Failures: 0 / 3 Successes: 0 Timeout: N/A

Downstream Service

Log messages will appear here...