Spring Cloud Spring Cloud Circuit Breaker & Resilience 2 — Questions and Answers
Question 1: What is the default sliding window type used by Resilience4j circuit breakers?
- COUNT_BASED (Correct answer)
- TIME_BASED
- RATE_BASED
- THRESHOLD_BASED
Correct answer: COUNT_BASED
Resilience4j defaults to a COUNT_BASED sliding window, which tracks the outcome of the last N calls to compute the failure rate.
Question 2: When does a Resilience4j circuit breaker enter the Half-Open state?
- After the waitDurationInOpenState has elapsed while the circuit is Open (Correct answer)
- When exactly 50% of requests are failing
- During initial circuit breaker startup
- When the fallback method is partially active
Correct answer: After the waitDurationInOpenState has elapsed while the circuit is Open
After waiting in Open state for waitDurationInOpenState duration, the circuit breaker transitions to Half-Open to allow probe calls and test if the downstream service has recovered.
Question 3: Which Resilience4j configuration property defines how long the circuit remains in Open state before transitioning to Half-Open?
- waitDurationInOpenState (Correct answer)
- openCircuitTimeout
- breakerResetTime
- recoveryDelay
Correct answer: waitDurationInOpenState
waitDurationInOpenState sets the duration the circuit breaker remains in Open state before switching to Half-Open to test recovery.
Question 4: Which Resilience4j pattern limits the number of concurrent calls to a service to isolate failures and prevent resource exhaustion?
- Bulkhead (Correct answer)
- Rate Limiter
- Circuit Breaker
- Retry
Correct answer: Bulkhead
The Bulkhead pattern limits concurrent calls to a service, isolating it so a spike of slow calls cannot exhaust shared resources and affect other services.
Question 5: What does the @RateLimiter annotation control when applied to a method in Resilience4j?
- The number of calls allowed within a configured time window (Correct answer)
- The speed of database read operations
- The network bandwidth consumed per request
- The CPU utilization threshold per service instance
Correct answer: The number of calls allowed within a configured time window
@RateLimiter restricts how many calls can be made to the annotated method within a defined time period, preventing downstream overload.
Question 6: What is the purpose of the 'permittedNumberOfCallsInHalfOpenState' property in Resilience4j?
- It defines how many probe calls are allowed through when the circuit is testing recovery in Half-Open state (Correct answer)
- It sets the maximum thread count during service recovery
- It limits request concurrency while the circuit initializes
- It controls the number of retry attempts in degraded mode
Correct answer: It defines how many probe calls are allowed through when the circuit is testing recovery in Half-Open state
permittedNumberOfCallsInHalfOpenState controls how many test requests are sent through in Half-Open state to determine if the downstream service has recovered.
Question 7: Which actuator endpoint exposes the current state and metrics of all Resilience4j circuit breakers in a Spring Boot application?
- /actuator/circuitbreakers (Correct answer)
- /actuator/health/circuit
- /actuator/resilience
- /actuator/breakers
Correct answer: /actuator/circuitbreakers
The /actuator/circuitbreakers endpoint, provided by resilience4j-spring-boot2/3, exposes real-time state and call statistics for all configured circuit breakers.
What is the default sliding window type used by Resilience4j circuit breakers?