Scrivio Interview library
InternalsFoundations5 min read · updated 12 November 2026

Describe the states of a Resilience4j circuit breaker and what moves it between them. What do failureRateThreshold, slidingWindowSize, minimumNumberOfCalls and waitDurationInOpenState control?

A Resilience4j circuit breaker starts CLOSED, letting calls through and recording their results in a sliding window. Once at least minimumNumberOfCalls have been recorded and the failure rate (or slow call rate) reaches failureRateThreshold, 50 percent by default, it moves to OPEN and rejects calls at once with CallNotPermittedException for waitDurationInOpenState, 60 seconds by default. Then it moves to HALF_OPEN, lets a small number of trial calls through, and goes back to CLOSED if they succeed or to OPEN if they fail; slidingWindowSize decides how many calls or seconds the rate is computed over.

Why this question is asked

A circuit breaker is the pattern that stops a failing dependency from dragging our service down with it. It is simple to describe, but the configuration values interact in ways that surprise people, and a breaker that opens too easily or never opens is worse than none. Interviewers ask about the states and parameters to check that we understand what the breaker actually measures. In this answer, we will recap the idea, walk through the three main states and each transition, explain the four parameters with their defaults, and see the whole thing in a small configuration.

1A Quick Recap of the Circuit Breaker Idea

The name comes from electrical circuits: when too much current flows, the breaker trips and cuts the circuit, protecting the wiring. In software, a circuit breaker sits around calls to a dependency. When the dependency keeps failing, the breaker stops sending calls to it for a while and fails fast instead.

Failing fast has two benefits. Our service stops wasting threads and time waiting on calls that will fail anyway, and the struggling dependency gets less traffic, which gives it a chance to recover. Resilience4j implements this as a small state machine with three normal states: CLOSED, OPEN and HALF_OPEN. It also has special states, DISABLED, FORCED_OPEN and METRICS_ONLY, that we set by hand for testing or operations.

2CLOSED: Calls Pass and Results Are Recorded

In the CLOSED state every call goes through to the dependency. After each call, the breaker records whether it succeeded, failed, or was slow, in a sliding window. The window is either count-based, the last N calls, or time-based, the calls in the last N seconds.

After every recorded call, the breaker computes two rates over the window: the failure rate, the percentage of calls that threw an exception it counts as a failure, and the slow call rate, the percentage that took longer than slowCallDurationThreshold. But it only does this once the window holds at least minimumNumberOfCalls results. Before that, it stays CLOSED whatever happens, because a rate over two calls means nothing. When either rate is at or above its threshold, the breaker moves to OPEN.

3OPEN: Failing Fast

In the OPEN state, the breaker does not call the dependency at all. Every call is rejected immediately with CallNotPermittedException, which takes microseconds instead of a full timeout. Our code typically catches this in a fallback and returns cached data or a clear error.

The breaker stays OPEN for waitDurationInOpenState, 60 seconds by default. When that time has passed, it moves to HALF_OPEN. By default this happens on the next call that arrives after the wait; with automaticTransitionFromOpenToHalfOpenEnabled set to true, a timer moves it even if no calls arrive.

4HALF_OPEN: Testing Whether the Dependency Has Recovered

In HALF_OPEN, the breaker lets through a limited number of trial calls, set by permittedNumberOfCallsInHalfOpenState (10 by default), and rejects the rest. When those trial calls have completed, it computes the failure and slow call rates over them alone. If the rates are below the thresholds, the dependency looks healthy and the breaker goes back to CLOSED with a fresh window. If they are still too high, it goes back to OPEN for another wait.

The reason for this middle state is to avoid flooding a service that has only just come back. Instead of sending full traffic at once, we probe with a few calls first.

Step throughResilience4j circuit breaker states
  1. CLOSEDcalls pass, results go into the sliding window
  2. At least minimumNumberOfCalls and rate >= threshold?
    YesMove to OPENNoStay CLOSED
  3. OPENreject with CallNotPermittedException
  4. Wait waitDurationInOpenState60 s by default
  5. HALF_OPENallow 10 trial calls by default
  6. Trial calls healthy?
    YesBack to CLOSEDNoBack to OPEN

6 steps in order. Play them, or step through them one at a time.

5The Four Parameters and Their Defaults

Now we can say exactly what each parameter controls. These are the documented defaults in Resilience4j 2.x; check your version, since defaults have changed before.

YAML
resilience4j:
circuitbreaker:
instances:
inventory:
sliding-window-type: COUNT_BASED
sliding-window-size: 50 # rate over the last 50 calls
minimum-number-of-calls: 20 # no decision before 20 calls
failure-rate-threshold: 50 # 10 failures in 20 calls -> OPEN
slow-call-duration-threshold: 2s
slow-call-rate-threshold: 80
wait-duration-in-open-state: 30s
permitted-number-of-calls-in-half-open-state: 5
Key circuit breaker settings
SettingControlsDefault
failureRateThresholdfailure percentage that opens the breaker50
slowCallRateThresholdslow call percentage that opens it100
slidingWindowTypecount-based or time-based windowCOUNT_BASED
slidingWindowSizecalls (count) or seconds (time) in the window100
minimumNumberOfCallscalls needed before any rate is computed100
waitDurationInOpenStatehow long OPEN lasts before HALF_OPEN60 s
permittedNumberOfCallsInHalfOpenStatetrial calls in HALF_OPEN10

Notice how minimumNumberOfCalls and slidingWindowSize work together. With the defaults, both are 100, so a breaker on a low-traffic endpoint may never see 100 calls and therefore never open. Notice also that with a time-based window, slidingWindowSize is in seconds, so 60 means the calls of the last minute, however many there were.

Which exceptions count as failures is configured too: recordExceptions lists the ones that count, ignoreExceptions lists the ones that count as neither success nor failure. Business errors such as a validation failure should normally be ignored, so they cannot open the breaker.

6Follow-up questions

What is the difference between a count-based and a time-based window?

A count-based window keeps the outcomes of the last N calls, so it reacts at the same speed whatever the traffic. A time-based window keeps the outcomes of the last N seconds in per-second buckets, so on high traffic it covers many calls and on low traffic few. Time-based windows suit endpoints with variable traffic, but minimumNumberOfCalls still applies.

Does an open circuit breaker count as a failure for a retry?

It throws CallNotPermittedException, and if the retry is configured to retry all exceptions, it will retry it pointlessly. We should configure the retry to ignore CallNotPermittedException so that an open breaker fails fast.

How can you see the breaker state in production?

Resilience4j publishes Micrometer metrics such as the breaker state and call counts by outcome, and Spring Boot Actuator can show breaker health. A dashboard of state transitions per breaker is the quickest way to see which dependency is failing.

7Conclusion

In this answer, we followed the Resilience4j circuit breaker through its states. In CLOSED it records outcomes in a count-based or time-based window, and once minimumNumberOfCalls is reached and the failure or slow call rate hits the threshold, it opens. In OPEN it rejects calls with CallNotPermittedException for waitDurationInOpenState, and in HALF_OPEN a few trial calls decide whether it closes again or reopens.

What to say in the interviewAbout 90 seconds aloud

Open with

A Resilience4j circuit breaker has three normal states. In CLOSED, every call goes through and its outcome is recorded in a sliding window, which is either the last N calls or the last N seconds, set by slidingWindowSize.

Then, if they want more

Once the window holds at least minimumNumberOfCalls results, it computes the failure rate and the slow call rate, and if either reaches its threshold, failureRateThreshold being fifty percent by default, it moves to OPEN. Before minimumNumberOfCalls is reached, it never opens, which is why a breaker with the default of one hundred can stay closed forever on a quiet endpoint.

In OPEN, it does not call the dependency at all and throws CallNotPermittedException immediately, so we fail fast and give the dependency room to recover. It stays open for waitDurationInOpenState, sixty seconds by default, and then moves to HALF_OPEN, either on the next call or automatically if that option is enabled.

In HALF_OPEN it allows a small number of trial calls, ten by default, and if they are healthy it closes again, otherwise it opens again for another wait. I would also mention that recordExceptions and ignoreExceptions decide what counts as a failure, so validation errors should not open the breaker, and that the retry should ignore CallNotPermittedException. Defaults change between versions, so I would always check them.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Describe the states of a Resilience4j circuit breaker and what moves it between them....": https://scrivio-interview-library.netlify.app/spring-boot/resilience/9565f7880d/

More in Resilience