Skip to content

section: blog/kubernetes-probes-liveness-readiness-startup

Liveness, readiness and startup probes: what each one is for

The three Kubernetes probes answer different questions. Mixing them up causes restart loops and dropped traffic. A practical guide to configuring each.

published 3 min read

Kubernetes gives every container three health checks. They look alike in YAML, but the kubelet acts on each one very differently. Most probe-related incidents come from asking one probe to do another's job.

Three probes, three questions

  • Liveness — Is this process wedged beyond recovery? On failure the kubelet restarts the container.
  • Readiness — Should this pod receive traffic right now? On failure the pod is removed from Service endpoints; nothing is restarted.
  • Startup — Has the application finished starting? Until it succeeds, liveness and readiness checks are not run at all.

Keeping these questions separate is most of the work. A liveness failure is a sledgehammer: it kills in-flight requests and resets in-memory state. Readiness is a traffic switch you can flip as often as needed.

When each Kubernetes probe runs and what a failure doesThe startup probe runs first and may fail until the app has booted. Once it succeeds, liveness and readiness probes run in parallel. Two readiness failures in a row (the example's failureThreshold) take the pod out of Service endpoints until it passes again, without a restart. Three liveness failures in a row restart the container.startupProbelivenessProbereadinessProbeboot: up to failureThreshold × periodSecondsstarted2 failures → out of endpoints(no restart)3 failures → restart
fig. 1When each probe runs. Liveness failures restart the container; readiness failures only take the pod out of rotation until it recovers.

Liveness: only for unrecoverable states

A liveness endpoint should check whether this process can make progress — for example, whether its event loop or worker threads respond. It should not check databases, caches or downstream APIs.

Readiness: dependencies and load shedding belong here

Readiness is the right place to report that a pod cannot serve useful responses: warm-up is incomplete, a required dependency is unreachable, or the pod is deliberately shedding load. Failing readiness lets traffic go to healthier replicas while the pod recovers on its own.

Be careful when every replica shares the same dependency: if readiness fails everywhere at once, the Service has no endpoints and clients get connection errors instead of a meaningful error response. For hard dependencies, serving a fast, explicit error is often better than going unready.

Startup: protecting slow starters

Before startup probes existed, slow-starting applications needed a large initialDelaySeconds on liveness, which also delayed detection of real hangs later on. A startup probe separates the two: it allows up to failureThreshold × periodSeconds for boot, then hands over to liveness with tight settings.

deployment.yamlyaml
containers:
  - name: api
    image: registry.example.com/api:1.4.2
    ports:
      - containerPort: 8080
    startupProbe:
      httpGet: { path: /healthz/live, port: 8080 }
      periodSeconds: 5
      failureThreshold: 24   # up to 120s to start
    livenessProbe:
      httpGet: { path: /healthz/live, port: 8080 }
      periodSeconds: 10
      timeoutSeconds: 2
      failureThreshold: 3
    readinessProbe:
      httpGet: { path: /healthz/ready, port: 8080 }
      periodSeconds: 5
      timeoutSeconds: 2
      failureThreshold: 2

Defaults worth knowing

Unless overridden, probes run every 10 seconds (periodSeconds), time out after 1 second (timeoutSeconds), and act after 3 consecutive failures (failureThreshold). The one-second timeout is the default most likely to hurt: a garbage-collection pause or a busy node can exceed it and produce false failures.

Readiness and graceful shutdown

When a pod is deleted, removing it from endpoints and sending SIGTERM happen concurrently. Load balancers and kube-proxy may keep routing to the pod for a short time after it starts shutting down. Two habits avoid dropped requests:

  1. Add a short preStop delay (an exec sleep, or the built-in sleep action on recent Kubernetes versions) so routing updates propagate before the process stops accepting connections.
  2. Handle SIGTERM by finishing in-flight requests within terminationGracePeriodSeconds.

A checklist

  • Liveness checks only the process itself; never a shared dependency.
  • Readiness reflects whether the pod can serve useful traffic now.
  • Slow starters get a startup probe instead of a long initial delay.
  • Timeouts are set deliberately rather than left at one second.
  • Shutdown is tested: deploy during a load test and confirm zero failed requests.