Bird
0
0

What will the health check endpoint return if the service is running but a dependent cache is unreachable?

medium📝 Analysis Q5 of 15
Microservices - Resilience Patterns
What will the health check endpoint return if the service is running but a dependent cache is unreachable?
function healthCheck() {
  if (service.isRunning() && cache.isAvailable()) {
    return { status: 200, message: 'OK' };
  } else {
    return { status: 500, message: 'Dependency Failure' };
  }
}
A{ status: 404, message: 'Not Found' }
B{ status: 200, message: 'OK' }
C{ status: 500, message: 'Dependency Failure' }
D{ status: 503, message: 'Service Unavailable' }
Step-by-Step Solution
Solution:
  1. Step 1: Check conditions for healthy response

    Both service.isRunning() and cache.isAvailable() must be true for 200 OK.
  2. Step 2: Determine output if cache is unreachable

    If cache.isAvailable() is false, else block returns 500 with 'Dependency Failure'.
  3. Final Answer:

    { status: 500, message: 'Dependency Failure' } -> Option C
  4. Quick Check:

    Dependency failure returns 500 status [OK]
Quick Trick: All dependencies must be healthy for 200 OK [OK]
Common Mistakes:
MISTAKES
  • Ignoring dependency status in health check
  • Confusing 500 with 503
  • Assuming 200 even if cache is down

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Microservices Quizzes