Stage 3 · Build
Production-Ready Services
Health Checks
Expose liveness and readiness endpoints that check database, Redis, queue, and dependency status.
Why Health Checks
Kubernetes, load balancers, and orchestrators need to know if your service is alive and ready to serve traffic. Health check endpoints provide this signal. Without them, traffic routes to broken instances.
Liveness vs Readiness
| Type | Purpose | Action on Failure |
|---|---|---|
| Liveness | Is the process alive? | Restart the container |
| Readiness | Can it serve traffic? | Remove from load balancer |
| Startup | Has initialization completed? | Wait before checking liveness |
Dependency Checks
Health Handler
Deep Health Checks
Monitoring
- Kubernetes livenessProbe: HTTP GET /healthz every 10s.
- Kubernetes readinessProbe: HTTP GET /readyz every 5s.
- Load balancer: Health check endpoint for target registration.
- Monitoring: Alert when health checks fail for > 1 minute.
Liveness checks should never call external services. If the database is down, the process is still alive. Only restart on deadlocks, out-of-memory, or unrecoverable errors.
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.