Middle
Tell me about the Circuit Breaker pattern. What is it used for, and what modes are available?
sobes.tech AI
Answer from AI
The Circuit Breaker pattern is used to increase the resilience of distributed systems by preventing repeated calls to a non-responsive or slow service.
Main idea: if a service starts to frequently return errors or respond slowly, the Circuit Breaker "opens" the circuit and temporarily blocks calls to that service, giving it time to recover and preventing system overload.
Operating modes:
- Closed: all requests pass as usual.
- Open: requests are immediately rejected without attempting to contact the service.
- Half-Open: after a waiting period, a limited number of test requests are sent to check if the service has recovered.
If the test requests are successful, it switches back to Closed; otherwise, it remains in Open.