Hire Me
Interactive Demo

Circuit Breaker State Machine

CLOSED → OPEN → HALF-OPEN → CLOSED Configurable thresholds · Live request stream · Sliding window
Closed
All calls pass through
failure rate ≥ threshold
half-open passes
Open
All calls short-circuit
wait duration elapses
test call fails
Half-Open
Limited test calls
Requests flowing normally
Sliding Window — last 10 calls 0.0% failures
Success
Failure
Slow
Failure Rate 0%
0
Total Calls
0
Failed
0
Rejected
0s
In State
State Transition Log
Configuration
Failure Threshold50%
Window Size10
Wait Duration8s
Half-Open Permits5
Inject Events
8
Seconds until Half-Open

Simulates Resilience4j CircuitBreaker with count-based sliding window. Building resilient Spring Boot services? Get in touch.

How it works

CLOSED
Normal operation — every call is forwarded to the downstream service. The circuit breaker tracks outcomes in a sliding window. When the failure rate exceeds the configured threshold, it trips to OPEN.
OPEN
The breaker has tripped. All calls are immediately short-circuited with a CallNotPermittedException — no call reaches the service. This gives the downstream system time to recover. After the wait duration, the breaker moves to HALF-OPEN.
HALF-OPEN
A probe state. A limited number of test calls are permitted through. If they succeed (failure rate below threshold), the breaker resets to CLOSED. If any fail, it goes back to OPEN and the wait restarts.
Sliding Window
Resilience4j uses a count-based or time-based sliding window to measure failure rate. This demo uses count-based: the last N calls are evaluated. Slow calls (calls that exceed a duration threshold) are counted as failures when the slow call rate threshold is also exceeded.
In Spring Boot
Configure via application.yml under resilience4j.circuitbreaker.instances. Use @CircuitBreaker(name="myService") on any @Service method. Wire Micrometer metrics via the Actuator dependency to expose state transitions to Prometheus.