Liveness and readiness checks

Observability and operations Junior Python 3.13+ PostgreSQL 17+ Reviewed By Best Latest Apps

Pick the fix

During a 30-second database failover, every API pod restarted, slowing recovery. Why?

Options
Hint 1 of 1

Which probe failure restarts a container?

Choose an answer, then open Show answer below to check it.

Show answer

Answer: A The liveness probe checked the database; move that check to readiness

Correct. Liveness failures restart; readiness only removes traffic.

Kubernetes restarts a container when liveness fails, but only stops sending traffic when readiness fails. Liveness should only ask 'is this process stuck?'; a database outage shouldn't restart every pod.

Why not the others?
  • B The readiness probe was too slow. Readiness failures don't restart pods.
  • C Too few replicas. They'd all restart too.
  • D The pods ran out of memory. Nothing points to memory.

30-second answer

Liveness asks 'is this process stuck beyond repair?' and a failure restarts it, so it should check only the process itself (it can serve a trivial request). Readiness asks 'should this instance get traffic now?' and a failure just removes it from the load balancer, so it can check warm-up and critical dependencies. Putting dependency checks in liveness is dangerous: a database blip makes every instance restart at once.

Practise saying it · 25 s. No recording, just a timer

Liveness vs readiness.

Say your answer out loud, then check which of these points you covered:

  • Liveness → restart
  • Readiness → traffic
  • No dependencies in liveness
  • Fail readiness on shutdown

Deep dive

Startup probes give slow-starting apps time before liveness kicks in.

Readiness should fail during graceful shutdown so traffic drains.

Keep checks cheap; they run every few seconds on every instance.

A deep health endpoint for humans and dashboards is separate from probes.

Common mistakes

  • Liveness that checks the database.
  • Readiness that always returns 200.
  • Expensive checks that add load.

Senior take & follow-ups

Define each by what a failure triggers, then what each should test.

Follow-up questions

Think of your answer first, then open the hint.

  1. What happens if liveness checks the DB and the DB is down?

    Show hint

    Every pod restarts in a loop, making recovery harder.

  2. When should readiness fail?

    Show hint

    During warm-up, shutdown, or when the instance can't serve.

Suggest a fix if something here is wrong or out of date.