Reputation: 53
I am trying to build a Resilience4J Circuitbreaker
using custom CircuitbreakerConfig
Using the following code to build CircuitbreakerConfig
CircuitBreakerConfig circuitBreakerConfig = CircuitBreakerConfig
.custom()
.slidingWindowSize(100)
.failureRateThreshold(50)
.slowCallRateThreshold(50)
.slowCallDurationThreshold(
Duration.ofMillis(1000))
.waitDurationInOpenState(
Duration.ofMillis(1000))
.recordExceptions(IOException.class,
FeignException.FeignServerException.ServiceUnavailable.class)
.ignoreExceptions(
FeignException.FeignServerException.InternalServerError.class)
.build();
CircuitBreaker circuitBreaker = CircuitBreaker.of("sample-cb", circuitBreakerConfig);
I am using this to make a HTTP Call. Which always takes more than 1000 milliseconds to respond. Ideally, CircuitBreaker should transition to OPEN state if 50 if first 100 calls are slow. But it is transitioning to OPEN state only after 100 calls.
Not able to understand this behaviour. Looking for help.
Upvotes: 1
Views: 3027
Reputation: 1907
It's because the default value of minimumNumberOfCalls
is 100.
The failure rate and slow call rate can only be calculated, if a minimum number of calls were recorded. For example, if the minimum number of required calls is 10, then at least 10 calls must be recorded, before the failure rate can be calculated. If only 9 calls have been evaluated the CircuitBreaker will not trip open even if all 9 calls have failed.
You can set it to 50.
Upvotes: 1
Reputation: 48
Remove failureRateThreshold as a test, my assumption is that it is considering a sum between failureRateThreshold and slowCallRateThreshold to take effect
Upvotes: 0