Spring / Resilience4j Interview questions
How can you optimize CircuitBreaker configuration for a high-throughput service?
On a high-throughput service, a COUNT_BASED sliding window with a reasonably large size (for example, 200-1000 calls) usually gives a more stable failure-rate signal than TIME_BASED, since traffic volume is already consistent enough that a count window won't lag behind reality.
Set minimumNumberOfCalls proportionally higher too - a value that made sense for a low-traffic service can trip the breaker off statistical noise once call volume is much higher.
Tune slowCallDurationThreshold against real p95/p99 latency from production metrics rather than a guessed number, since a threshold set too aggressively will start treating normal tail latency as failures and open the breaker on healthy traffic.
Finally, keep waitDurationInOpenState and permittedNumberOfCallsInHalfOpenState tuned so that reopening after a real outage doesn't itself create a thundering-herd of trial calls the moment the breaker moves to HALF_OPEN - a small permitted count with a short additional ramp-up is usually safer than flipping straight back to full traffic.
More Related questions...