Scaling

Health check

Definition

A health check is a lightweight request or signal sent at a fixed interval to determine whether an instance is alive and ready to serve; failing a threshold of checks removes it from service.

In practice

Interval and thresholds trade detection speed against flapping: checking every 5 seconds with 3 failures to mark unhealthy means up to 15 seconds of traffic still reaches a dead server. Kubernetes separates liveness (restart me) from readiness (send me traffic).

A health check that only returns 200 proves the process is running, not that it can do useful work. Checking every dependency is the opposite trap: one slow database can then mark the whole fleet unhealthy at once and turn a partial outage into a total one.

Example

A load balancer calls GET /health/ready every 10 seconds, removes an instance after 2 consecutive failures and adds it back after 3 consecutive successes.