Resilience4j version: 1.1.0
Java version: 11
Using Spring Boot 2 annotations.
Problem description: If you are using slidingWindowType = TIME_BASED, you are limited to 100 recorded calls, this brings a problem, if amount of requests is not enough to fill this bucket, circuit breaker won't work. For example if you window is 5 min, and you get 10 requests a minute, your circquit breaker won't even try to detect issues. And you cannot lower bucket size to 40 or 50 because code don't alow it.
Issue is inside io.github.resilience4j.circuitbreaker.internal.CircuitBreakerMetrics.java
if(slidingWindowType == CircuitBreakerConfig.SlidingWindowType.COUNT_BASED){
this.metrics = new FixedSizeSlidingWindowMetrics(slidingWindowSize);
this.minimumNumberOfCalls = Math.min(circuitBreakerConfig.getMinimumNumberOfCalls(), slidingWindowSize);
}else{
this.metrics = new SlidingTimeWindowMetrics(slidingWindowSize);
this.minimumNumberOfCalls = circuitBreakerConfig.getMinimumNumberOfCalls();
}
In case it's not COUNT_BASED, it is using .getMinimumNumberOfCalls(), and minimumNumberOfCalls is equals to default value -> 100
private int minimumNumberOfCalls = DEFAULT_MINIMUM_NUMBER_OF_CALLS;
Cheers
Hi,
you can still configure minimumNumberOfCalls if you are using SlidingWindowType.TIME_BASED to reduce the minimum number of calls per sliding time window.
You don't have to use the default value.
Thank you, looks like minimumNumberOfCalls is working fine :)
Also, if we use COUNT_BASED type, between slidingWindowSize and minimumNumberOfCalls values, the smallest is used as recorded value buffer size?
p/s not very clearly explained in docs...
Yes, but if you use COUNT_BASED, you should configure minimumNumberOfCalls to eb smaller than slidingWindowSize. Otherwise it doesn't make sense.
Anyway the code uses the smaller value. If slidingWindowSize = 5 and minimumNumberOfCalls = 10, then the code adapts it to minimumNumberOfCalls = 5
good, thank you