What if your system could tell you it's sick before your users do?
Why Health check endpoints in HLD? - Purpose & Use Cases
Imagine you run a busy online store. You want to know if your website is working well. Without a health check, you have to open the site yourself or ask customers if it works. This is like calling every store branch to ask if they are open.
Checking manually is slow and tiring. You might miss problems until customers complain. It's like waiting for a fire alarm instead of having smoke detectors. You lose time fixing big issues that could have been caught early.
Health check endpoints are special URLs that tell you if your system is healthy. They work like automatic smoke detectors. Your monitoring tools can call these endpoints regularly to get quick yes/no answers about your system's status.
Open browser -> Visit site -> See if page loadsGET /health -> 200 OK means system is healthyHealth check endpoints let you catch problems early and keep your system running smoothly without waiting for user complaints.
A bank uses health check endpoints to monitor its ATM network. If an ATM stops responding, the system alerts technicians immediately to fix it before customers notice.
Manual checks are slow and unreliable.
Health check endpoints provide quick, automatic status updates.
They help keep systems stable and users happy.
Practice
Solution
Step 1: Understand the role of health check endpoints
Health check endpoints are designed to tell if a service is alive and working properly.Step 2: Identify the correct purpose among options
Only To verify if the service is alive and functioning describes checking the service's health, while others describe unrelated functions.Final Answer:
To verify if the service is alive and functioning -> Option AQuick Check:
Health check = Verify service alive [OK]
- Confusing health check with authentication
- Thinking health check stores data
- Assuming health check serves website content
Solution
Step 1: Recall standard health check paths
Readiness endpoints typically use the path/readyto indicate if the service is ready to accept traffic.Step 2: Match the correct path
Among the options, only/readyis the standard path for readiness checks.Final Answer:
/ready -> Option AQuick Check:
Readiness path = /ready [OK]
- Using /health for readiness instead of liveness
- Confusing /status or /check as standard paths
- Mixing readiness and liveness endpoints
if database.isConnected() and cache.isAvailable():
return 200
else:
return 503What HTTP status code will the endpoint return if the database is connected but the cache is down?
Solution
Step 1: Analyze the condition logic
The endpoint returns 200 only if both database.isConnected() and cache.isAvailable() are true.Step 2: Evaluate the given scenario
Database is connected (true), cache is down (false), so condition fails and returns 503.Final Answer:
503 -> Option BQuick Check:
Both must be true for 200; else 503 [OK]
- Assuming 200 if only one service is healthy
- Confusing 503 with 404 or 500
- Ignoring the AND condition in the code
def health_check():
if db.connected() or cache.available():
return 200
else:
return 503What is the main problem with this health check logic?
Solution
Step 1: Understand the logical operator used
The code uses OR, so it returns 200 if either db.connected() or cache.available() is true.Step 2: Identify the issue with health check accuracy
This means it reports healthy even if one service is down, which can mislead monitoring systems.Final Answer:
It returns 200 even if only one service is healthy -> Option CQuick Check:
OR allows partial health, which is incorrect [OK]
- Using OR instead of AND in health checks
- Ignoring partial failures in health status
- Misinterpreting HTTP status codes
/health endpoint for liveness and a /ready endpoint for readiness. Which of the following best describes when the /ready endpoint should return HTTP 503?Solution
Step 1: Understand readiness vs liveness
Liveness (/health) checks if service is alive; readiness (/ready) checks if it can handle requests safely.Step 2: Identify readiness failure condition
Readiness returns 503 if dependencies (like database) are missing, so service should not receive traffic yet.Final Answer:
When the service is alive but not ready to accept traffic due to missing dependencies -> Option DQuick Check:
Readiness 503 = alive but not ready [OK]
- Confusing liveness failure with readiness failure
- Returning 503 when service is fully down (should be liveness)
- Assuming overload means readiness failure
Ready to prove it?
Pass the test and this pattern moves unknown
