Timeout Windows and Reset Logic
You'll learn: How to configure the duration a circuit breaker stays open before attempting recovery and transitioning to half-open state.
When a circuit breaker trips to the open state after detecting failures, it can't stay open forever—that would prevent you from ever discovering if the downstream service has recovered. The timeout window (also called the "reset timeout" or "sleep window") is the configured duration the circuit waits in the open state before attempting recovery.
How It Works
Once the circuit enters the open state and starts fast-failing requests, a timer begins. After the timeout window elapses, the circuit breaker automatically transitions to the half-open state. In this state, it permits a limited number of test requests to probe whether the downstream service has recovered.
Think of it like a fire alarm cooldown: after the alarm triggers and everyone evacuates, you don't immediately rush back in. You wait a safe period (the timeout window) before cautiously checking if it's safe to return (half-open state).
Configuration Considerations
The timeout window should reflect:
- Recovery time expectations: How long does your dependency typically need to recover? A database might need 30 seconds, while a memory cache might recover in 5 seconds.
- Business impact: Shorter windows mean faster recovery attempts but more probing traffic during actual outages.
- Cascading effects: Too short, and you risk repeatedly hammering a struggling service.
Common values range from 5-60 seconds, though mission-critical paths might use shorter windows.
After each failed recovery attempt in half-open state, the circuit returns to open and the timeout window timer resets—this prevents premature recovery declarations.
Key Takeaway: The timeout window balances service protection with recovery speed, determining how long your circuit breaker waits before cautiously testing if a failed dependency has recovered.