Health checks are read by load balancers, orchestrators and monitoring tools to decide whether an instance should get traffic, be restarted, or count as "up". A well-designed endpoint keeps bad instances out of rotation. A badly designed one takes every instance out at once and turns a small blip into a full outage.

Two questions, two endpoints

EndpointQuestionIf it fails
Liveness (/health/live)Is the process alive and not stuck?The orchestrator restarts it
Readiness (/health/ready)Can this instance serve traffic right now?It is removed from the load balancer until it recovers

Keep them separate. A liveness check that tests the database restarts every pod when the database blips, and restarted pods cannot fix a database.

What liveness should check

Almost nothing: that the process can respond. Return 200 from a handler that does not touch dependencies. If your runtime can deadlock (a stuck event loop, a deadlocked thread pool), a liveness check that runs on the main request path catches it.

What readiness should check

Whether this instance can do its job:

  • It has finished starting (configuration loaded, caches warmed, migrations checked).
  • Critical local resources are available (for example, it is not shutting down).
  • Optionally, critical dependencies it cannot work without, with short timeouts.

Be careful with dependencies. If every instance's readiness fails because the database is slow for two seconds, the load balancer removes all of them, and users get 503 errors instead of slightly slow responses. Prefer checking dependencies with a short timeout and failing readiness only after several consecutive failures, or not at all for dependencies that only some requests need.

A small implementation

let shuttingDown = false;
process.on('SIGTERM', () => { shuttingDown = true; });

app.get('/health/live', (_req, res) => res.status(200).json({ status: 'ok' }));

app.get('/health/ready', async (_req, res) => {
  if (shuttingDown) return res.status(503).json({ status: 'shutting_down' });
  const db = await withTimeout(pool.query('SELECT 1'), 500).then(() => 'ok', () => 'fail');
  const ok = db === 'ok';
  res.status(ok ? 200 : 503).json({ status: ok ? 'ok' : 'degraded', checks: { database: db } });
});

Response format

Return a status code that machines understand (200 healthy, 503 not ready) and a small JSON body that humans can read: overall status, per-check status and the version. Never include secrets, connection strings or stack traces.

{ "status": "ok", "version": "2026.10.23-1", "checks": { "database": "ok", "cache": "ok" } }

Security

Health endpoints are often public because load balancers and uptime tools call them. Keep the public response minimal, put detailed diagnostics behind authentication or on an internal port, and rate-limit them like any other endpoint.

Using health checks for monitoring

An uptime check on the readiness endpoint is a cheap way to test the whole backend from outside: if it returns 200 with "status":"ok", the service and its critical dependencies answered. Pair it with checks on real pages, because a healthy backend can still serve a broken front-end. See how to monitor website uptime.

Common mistakes

  • One endpoint for liveness and readiness, so dependency problems cause restart loops (CrashLoopBackOff).
  • No timeouts on dependency checks, so a hung database makes health checks hang too.
  • Expensive checks (full queries, external API calls) run every few seconds by many callers.
  • Always returning 200, even during shutdown, so load balancers keep sending traffic to a dying instance.
  • Checking only the health endpoint in monitoring, missing broken pages and journeys.

Kubernetes probes

Kubernetes maps these ideas directly to liveness, readiness and startup probes. The details, including timings, are in Kubernetes probes explained.

In VitalRix

HTTP checks can call your readiness endpoint and assert on the status code and a JSON field such as status, from several regions. When a check fails, the incident links to the traces and logs from the same minutes, so you can see which dependency failed. See API monitoring.

A worked example: the outage a health check caused

A team's readiness endpoint ran SELECT 1 on the primary database and called the payment provider's status API. One evening the payment provider's status API slowed to 3 seconds. Every pod's readiness timed out within the same minute, Kubernetes removed them all from the Service, and the entire site returned 503 even though only payments were affected. Removing the payment check from readiness, and moving it to a dashboard and an alert, turned the next payment-provider slowdown into a degraded checkout instead of a full outage.

Checklist

  1. Separate liveness and readiness endpoints.
  2. Liveness checks only the process.
  3. Readiness checks startup state and only the dependencies the instance cannot work without, with short timeouts.
  4. Readiness fails during shutdown.
  5. Minimal public response; details behind authentication.
  6. An uptime check on readiness plus checks on real pages.
Should my health check test the database?

Readiness may, with a short timeout and tolerance for brief blips. Liveness should not, or a database issue will restart every instance.

What status code should an unhealthy check return?

503 Service Unavailable is the common choice; load balancers and orchestrators treat any non-2xx as unhealthy.

How often should health checks run?

Load balancers often every 5 to 10 seconds; uptime monitoring every minute. Keep the endpoint cheap.

Try VitalRix free

Uptime monitoring, APM, logs, real user monitoring and status pages in one place. No credit card needed.