Spring / Resilience4j Interview questions
What is the difference between COUNT_BASED and TIME_BASED sliding windows?
| COUNT_BASED | TIME_BASED |
| Window holds a fixed number of the last N calls. | Window holds calls from the last N seconds. |
| Rate stays stable regardless of traffic bursts. | Rate can shift quickly during traffic spikes or lulls. |
| Simple to reason about for steady, predictable traffic. | Better reflects real-time health during uneven traffic. |
With COUNT_BASED, a burst of calls in one second and none in the next ten are all evaluated together once N calls accumulate, which can make the rate feel "stale" under bursty traffic.
With TIME_BASED, an idle period simply produces fewer calls in the window, so a low-traffic service might take longer to accumulate the minimumNumberOfCalls needed for the breaker to react at all.
More Related questions...