Skip to main content
networking

Health Check

A health check is a periodic probe that determines whether a service instance is able to handle traffic. Load balancers, orchestrators (Kubernetes), and service meshes use health checks to route traffic only to healthy instances. Types: liveness (is the process alive?), readiness (can it serve requests?), and startup (has it finished initializing?).

Definition

Health checks are probes that verify service availability. A health check endpoint (typically GET /health or GET /healthz) returns HTTP 200 when the service can handle requests and 503 when it cannot. The probe can verify: database connectivity, cache availability, disk space, downstream dependency reachability, and internal state consistency. Kubernetes defines three probe types: liveness (restart the pod if it fails – detect deadlocks), readiness (remove from service if it fails – detect temporary inability to serve), and startup (give slow-starting apps time before liveness kicks in). Load balancers (ALB, Nginx, HAProxy) use health checks to remove failed backends from the pool. Probe parameters: interval (how often to check), timeout (how long to wait), threshold (failures before marking unhealthy), and success threshold (successes before marking healthy again). A health check that always returns 200 regardless of internal state provides false confidence – validate actual functionality.

Examples

  • Kubernetes: livenessProbe: { httpGet: { path: /healthz, port: 8080 }, periodSeconds: 10 }
  • ALB health check: path=/health, interval=30s, unhealthyThreshold=3
  • app.get('/health', (req, res) => db.ping().then(() => res.sendStatus(200)).catch(() => res.sendStatus(503)))

Related Protocols

Related Terms