What if your system could tell you it's sick before it breaks down?
Why Health checks in HLD? - Purpose & Use Cases
Imagine you run a busy restaurant kitchen. You have many cooks and machines working together. Without a way to check if each cook or machine is working well, you might only notice problems when the food is late or cold.
Manually checking each cook or machine all the time is slow and tiring. You might miss problems or get false alarms. This causes delays and unhappy customers because issues are found too late or not at all.
Health checks are like having a smart assistant who regularly checks each cook and machine automatically. It quickly tells you if something is wrong so you can fix it before customers notice.
Check each server by logging in and running commands one by one.
Use automated health check endpoints that report status instantly.
Health checks let systems detect and fix problems fast, keeping services reliable and users happy.
Websites use health checks to know if their servers are up and ready. If a server fails, traffic is sent elsewhere without users seeing errors.
Manual checks are slow and error-prone.
Health checks automate status monitoring.
This keeps systems healthy and users satisfied.
Practice
Solution
Step 1: Understand health check purpose
Health checks are used to confirm if parts of a system are functioning correctly.Step 2: Compare options with purpose
Only To verify if system components are working properly matches this purpose; others relate to unrelated system improvements.Final Answer:
To verify if system components are working properly -> Option AQuick Check:
Health check = Verify system health [OK]
- Confusing health checks with performance tuning
- Thinking health checks change system features
- Assuming health checks increase capacity
Solution
Step 1: Identify typical health check method
Health checks often use simple HTTP GET requests to return system status.Step 2: Eliminate unrelated options
Database queries, login forms, and file uploads are not standard health check methods.Final Answer:
A simple HTTP GET request returning status -> Option DQuick Check:
Health check = Simple HTTP GET [OK]
- Choosing complex operations for health checks
- Confusing health checks with user features
- Selecting unrelated services like file upload
function healthCheck() {
if (database.isConnected() && cache.isAvailable()) {
return 200;
} else {
return 503;
}
}What HTTP status code will be returned if the database is connected but the cache is down?
Solution
Step 1: Analyze condition in code
The code returns 200 only if both database and cache are healthy.Step 2: Apply given scenario
Database is connected (true), cache is down (false), so condition fails and returns 503.Final Answer:
503 -> Option AQuick Check:
Partial failure returns 503 [OK]
- Assuming 200 if any component is healthy
- Confusing 503 with 404 or 500
- Ignoring the AND condition in code
Solution
Step 1: Understand health check logic
If the endpoint returns 200 even when the database is down, it likely does not check the database.Step 2: Evaluate other options
Database being up contradicts the problem; 200 means success, not failure; cache status irrelevant here.Final Answer:
The health check does not verify the database connection -> Option CQuick Check:
Missing DB check causes false 200 [OK]
- Misinterpreting HTTP 200 as failure
- Assuming database is up without proof
- Ignoring health check code logic
Solution
Step 1: Understand distributed system health
Overall health depends on all critical services working well, not just one.Step 2: Evaluate options for accuracy
Aggregating health from all critical services gives a true picture; checking only main or any one service is incomplete; skipping checks loses visibility.Final Answer:
Aggregate health from all critical services before responding -> Option BQuick Check:
Aggregate all critical services for true health [OK]
- Checking only one service in distributed system
- Assuming any healthy service means overall health
- Skipping health checks to save resources
Ready to prove it?
Pass the test and this pattern moves unknown
