A circuit breaker prevents repeated calls to a failing or slow service from delaying users. After a configured number of errors within a time window, it opens, skips the service, and fails fast until the reset interval expires. section 10.3.5
Model the breaker with these states and transitions:
- Closed: send requests normally and record failures. section 10.3.5
- Open: stop calling the unhealthy service and return an error immediately. section 10.3.5
- After the reset interval, test the service; a successful test closes the breaker, while a failed test keeps it open. A simplified implementation may omit this half-open state. section 10.3.5
Protecting an inventory request
Wrap an asynchronous inventory callback with a breaker configured for a 0.5-second timeout, a five-second failure window, three allowed failures, and a 30-second reset interval. Repeated slow calls then fail fast instead of blocking the backend-for-frontend response. section 10.3.5 section 10.3.5
Figure 10.3 A circuit breaker that opens after two failures. Once opened, all requests will fail instantly.
Trace the breaker opening after two failures and observe subsequent requests failing instantly. section 10.3.5





