Bird
0
0

Identify the error in this retry pattern pseudocode:

medium📝 Analysis Q6 of 15
Microservices - Advanced Patterns
Identify the error in this retry pattern pseudocode:
attempts = 0
while attempts < maxRetries:
  callService()
  if success:
    break
  attempts += 1
  sleep(0)
AThe loop condition should be attempts <= maxRetries
BSleeping zero seconds causes no delay between retries
CThe success condition is checked after incrementing attempts
DThe callService() should be outside the loop
Step-by-Step Solution
Solution:
  1. Step 1: Analyze sleep(0) effect

    Sleeping zero seconds means no wait between retries, causing rapid retries.
  2. Step 2: Understand retry best practice

    Retries should have delay (e.g., exponential backoff) to avoid overload.
  3. Final Answer:

    Sleeping zero seconds causes no delay between retries -> Option B
  4. Quick Check:

    Retry delay needed, sleep(0) is error [OK]
Quick Trick: Retry delay must be > 0 to avoid rapid retries [OK]
Common Mistakes:
  • Ignoring retry delay importance
  • Confusing loop condition boundaries
  • Misplacing success check

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Microservices Quizzes