Back to glossary

Circuit Breaker

A resilience pattern that monitors for failures in downstream service calls and temporarily stops making requests when a failure threshold is exceeded, preventing cascade failures across the system.

The circuit breaker pattern works like an electrical circuit breaker. In the closed state, requests flow normally. When failures exceed a threshold (e.g., 50% error rate over 10 seconds), the circuit opens, and subsequent requests fail immediately without calling the downstream service. After a cooldown period, the circuit enters a half-open state, allowing a few test requests to determine if the service has recovered.

This pattern prevents a failing downstream service from taking down the entire system. Without circuit breakers, a slow or failing dependency causes requests to queue up, consuming thread pools and memory, eventually cascading the failure to upstream services and creating system-wide outages.

For AI systems that depend on external model APIs, circuit breakers are essential. If an LLM provider experiences degraded performance or outages, a circuit breaker can immediately fail over to a cached response, a simpler model, or a graceful fallback experience rather than letting requests pile up and degrade the entire application.

Related Terms