/health, and that endpoint runs SELECT 1 against the database so the load balancer only sends traffic to instances that can really serve requests. This looks careful. Then the shared database slows down for a minute, and the load balancer marks every instance unhealthy at once, including the ones that could still serve cached pages, static assets, or anything that never touches the database. The question to ask about any health check is what it does when a dependency is slow rather than dead.
The terms come up throughout, so here they are first. A shallow health check confirms the process is running, listening on its port, and able to answer a basic request, usually with an HTTP 200 OK. A deep health check also probes external dependencies such as the database, a cache, or another API before it answers. The Safeguard write-up on how health checks cascade uses these same definitions.
What the health checker does on every probe
periodSeconds, timeoutSeconds, and failureThreshold as the knobs.
As an illustrative example: with a 10 second interval, a 5 second timeout, and an unhealthy threshold of 3, a target that stops answering is pulled after roughly 30 seconds. Nothing in that state machine knows why the probe failed. A crashed process and a slow database query produce the same result.
What a stalled database does to a deep check
- The probe request arrives and the handler asks the connection pool for a database connection.
- Real user traffic is also stuck waiting on the slow database, so the pool may already be empty. The handler waits for a connection to be returned.
- If it gets a connection, it sends
SELECT 1, which waits behind whatever is slowing the server. - The load balancer's timer expires first. It closes its side and records a failure. The handler may still be holding a worker thread and a pool slot after the prober has given up.
Why every instance fails in the same window
Choosing what the endpoint should test
- Good candidates: the process is up and its request loop answers, configuration loaded, local disk writable if the app needs it, and anything per-instance, such as a local sidecar or a cache running on the same host.
- Usually keep out: the shared primary database, a shared Redis cluster, third-party APIs, and anything else every instance talks to.
Checking your own setup
BASH
curl -s -o /dev/null -w '%{http_code} %{time_total}
' http://127.0.0.1:8080/healthYAML
livenessProbe:
httpGet:
path: /livez
port: 8080
periodSeconds: 10
timeoutSeconds: 2
failureThreshold: 3
readinessProbe:
httpGet:
path: /readyz
port: 8080
periodSeconds: 5
timeoutSeconds: 2
failureThreshold: 3/livez should only confirm that the process can answer. /readyz can include per-instance readiness, such as startup having finished. For a non-Kubernetes load balancer, find the same values in its target group or backend settings: the path, interval, timeout, and thresholds. Then work out how many seconds of database slowness it takes to empty the pool of healthy targets.
The practical test is short. For every dependency your health endpoint touches, ask whether all instances share it and what the endpoint does when it stops answering without failing. If all instances share it, take it out of the routing check, monitor it on its own, and let individual routes degrade when it slows down. A slow database will still hurt, but it will hurt only the requests that need it.