Health Check Patterns
ELI5 — The Vibe Check
Health checks are like the doctor's checkup for your servers. The load balancer periodically asks 'are you alive? are you healthy?' and routes traffic only to servers that respond positively. Sick servers get taken off the roster.
Real Talk
Patterns for monitoring service health in distributed systems. Liveness checks verify a service is running; readiness checks verify it can serve traffic; deep health checks verify dependencies (database, cache) are accessible. Health checks are used by load balancers, Kubernetes, and service meshes to route traffic and trigger restarts.
Show Me The Code
// Express health check endpoint
app.get('/health', (req, res) => {
res.json({ status: 'ok' });
});
app.get('/health/ready', async (req, res) => {
try {
await db.query('SELECT 1');
res.json({ status: 'ready', db: 'connected' });
} catch (e) {
res.status(503).json({ status: 'not ready' });
}
});
When You'll Hear This
"The load balancer hits /health every 10 seconds and removes servers that fail 3 consecutive checks." / "Separate liveness from readiness checks — a service can be alive but not ready to serve traffic."
Related Terms
Kubernetes
Kubernetes is a robot manager for your containers.
Load Balancer
A load balancer is like a traffic cop for servers.
Monitoring
Monitoring is keeping a constant eye on your app while it runs — tracking whether it's up, how fast it responds, how many errors it throws, and how much me...
Service Discovery
Service discovery is how microservices find each other without hardcoding addresses.