What is Circuit Breaker
Pattern for protecting from cascading failures
Circuit Breaker — Pattern for Protecting from Cascading Failures
Circuit Breaker is an architectural pattern in microservices that prevents cascading failures when a dependent service becomes unavailable.
Circuit Breaker States
| State | Description | Behavior | |-------|-------------|----------| | Closed | Normal operation | Requests pass through | | Open | Service unavailable | Requests blocked | | Half-Open | Testing | Allows test requests |
Configuration Parameters
- Failure Threshold — errors to open (5-10)
- Success Threshold — successes to close (3-5)
- Timeout — response wait time (1-5 sec)
- Reset Timeout — time to Half-Open (30-60 sec)
Configuration Example
circuit_breaker:
failure_threshold: 5
success_threshold: 3
timeout: 3000ms
reset_timeout: 30s
Libraries and Tools
- Resilience4j — Java
- Polly — .NET
- Hystrix — Java (deprecated)
- Istio — Service Mesh