Spring / Resilience4j Interview questions
How does the sliding window work in CircuitBreaker?
The sliding window is the pool of most recent call outcomes the CircuitBreaker uses to calculate its failure rate and slow-call rate, rather than looking at the entire call history since startup.
In COUNT_BASED mode, the window holds a fixed number of the most recent calls - for example, the last 100 - and the oldest result is dropped as each new one comes in.
In TIME_BASED mode, the window instead spans a fixed number of the most recent seconds, bucketed internally, so calls outside that time span no longer count regardless of how many calls happened.
Either way, the breaker only evaluates the failure rate once minimumNumberOfCalls worth of data exists in the window, which avoids tripping the breaker off a tiny, statistically meaningless sample.
More Related questions...