Half-Open State Testing
You'll learn how a circuit breaker carefully tests if a failed service has recovered before fully restoring normal traffic.
What Is Half-Open State Testing?
When a circuit breaker enters the half-open state, it doesn't immediately flood the recovered service with all requests. Instead, it allows a limited number of test requests through to verify the service is truly healthy. Think of it like opening a door just a crack to peek outside before fully opening it.
This is the critical "trial period" between complete failure (open state) and full restoration (closed state).
Why Limited Testing?
If the service is still unstable or only partially recovered, sending full traffic would:
- Overwhelm it again immediately
- Trigger another cascade failure
- Waste the recovery time already invested
By testing with just a few requests, you minimize risk while gathering real evidence of health.
How It Works
When the timeout window expires and the circuit moves from open to half-open:
- Allow N test requests through (e.g., 3-5 requests)
- Monitor their outcomes closely
- If all succeed: transition to closed (fully restored)
- If any fail: transition back to open (still broken, reset timer)
The test request count should be small enough to protect the service but large enough to confidently detect recovery.
Example Scenario
Your payment service circuit breaker has been open for 30 seconds. It transitions to half-open and allows 3 test transactions. If all 3 complete successfully within the timeout threshold, the circuit closes and normal traffic resumes. If even 1 fails, the circuit reopens for another 30-second cooling period.
Key Takeaway: Half-open state testing uses a small number of controlled requests to verify service recovery before fully closing the circuit, protecting fragile services during their recovery phase.