Video in progress
How can a wrongly configured liveness or readiness probe in Kubernetes take down a whole service?
If you check the DB or another service inside liveness, then when the DB slows down all pods restart at once and the service stops on its own. Liveness should check only "is the process alive", and readiness "is it ready to take traffic".
📖 Answer
This is how it happens on prod: liveness points at /actuator/health, which also checks the DB. The DB slows down for 10 seconds → health is DOWN on every pod → the kubelet restarts them all → until they come up (30–60 seconds in Spring) there's no pod accepting traffic → even after the DB recovers, the service stays dead for half a minute. And the wave of reconnections during the restart hits the DB again.
The right separation:
- Liveness — "has the process frozen?". Only the application itself: a deadlock, a stopped event loop. No external dependencies. If it fails — restart.
- Readiness — "can I take a request right now?". Is warm-up finished, are the needed dependencies there. If it fails, the pod is removed from the Service endpoints, but not restarted.
- Startup probe — for slow-starting applications; liveness isn't checked until it passes.
Spring Boot 3 provides these separately:
management:
endpoint.health.probes.enabled: true
endpoint.health.group.readiness.include: readinessState,db
# liveness: /actuator/health/liveness (livenessState only)
# readiness: /actuator/health/readiness
Be careful adding dependencies to readiness, too: if the DB is the same for all pods, when it goes down every pod becomes "not ready" and the LB returns 503. Sometimes that's right, and sometimes it would have been better to serve partially from the cache.
Think about the timeout and failureThreshold as well: a GC pause can be 2 seconds, and a 1-second timeout shouldn't kill a pod on a single attempt.
Sign up to mark studied questions and save your progress.