advanced

Readiness / liveness probes

Use readiness to control traffic eligibility and liveness to recover deadlocked or permanently broken processes.

Readiness probes control traffic eligibility. Liveness probes decide whether Kubernetes should restart a container. They solve different problems and should not blindly share the same endpoint.

					readinessProbe:
  httpGet:
    path: /health/ready
    port: 3000
  periodSeconds: 5
  failureThreshold: 3
livenessProbe:
  httpGet:
    path: /health/live
    port: 3000
  initialDelaySeconds: 30
  periodSeconds: 10
				

During graceful shutdown, readiness should fail first so load balancers stop sending traffic while in-flight work drains.

On interviews: slow startup, database outages, deadlocks, warm caches, graceful shutdown, and tuning `initialDelaySeconds`.

Common pitfalls: aggressive liveness restarts slow-but-healthy services; readiness that ignores dependency loss routes to broken instances.

The trade-off is fast failure detection versus restart storms during partial outages.

Checklist:

  • Readiness gates traffic.
  • Liveness targets stuck processes only.
  • Tune delays and thresholds per app startup.
  • Flip readiness false before termination.