Bird
0
0

Consider this pseudocode for a circuit breaker:

medium📝 Analysis Q13 of 15
Microservices - Resilience Patterns
Consider this pseudocode for a circuit breaker:
if state == 'OPEN':
  return 'fail fast'
elif state == 'HALF_OPEN':
  if test_call_successful():
    state = 'CLOSED'
  else:
    state = 'OPEN'
else:
  call_service()
What happens when the circuit breaker is in HALF_OPEN state and the test call fails?
AThe state changes to CLOSED and service calls continue
BThe state remains HALF_OPEN and retries immediately
CThe service call is ignored without state change
DThe state changes back to OPEN and calls are blocked
Step-by-Step Solution
Solution:
  1. Step 1: Analyze HALF_OPEN state logic

    In HALF_OPEN, a test call checks if the service recovered. If it fails, the state changes to OPEN.
  2. Step 2: Understand consequence of failure

    Changing to OPEN blocks further calls to prevent overload.
  3. Final Answer:

    The state changes back to OPEN and calls are blocked -> Option D
  4. Quick Check:

    HALF_OPEN fail -> OPEN state [OK]
Quick Trick: Failed test call in HALF_OPEN resets to OPEN [OK]
Common Mistakes:
MISTAKES
  • Assuming state changes to CLOSED on failure
  • Thinking retries happen immediately in HALF_OPEN
  • Ignoring state changes on test failure

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Microservices Quizzes