What is the difference between liveness and readiness endpoints?
IntermediateConceptTesting, services & metrics
Answer
- Liveness (
/healthz,/livez): "is the process alive and not deadlocked?" Must be cheap and must not check dependencies. If it fails, Kubernetes restarts the container. - Readiness (
/readyz): "can I serve traffic right now?" Checks critical dependencies (DB, cache) with short timeouts. If it fails, the pod is removed from Service endpoints but not restarted.
Checking the database in liveness is a classic mistake: a DB blip restarts every pod at once and turns a partial outage into a full one.
More on Testing, services & metrics
Why should automation scripts have tests at all?BeginnerHow does pytest discover and run tests?BeginnerWhy does pytest use plain `assert` instead of `assertEqual`?BeginnerWhat are pytest fixtures, and what scopes exist?IntermediateWhat built-in fixtures do you use most?IntermediateHow does `@pytest.mark.parametrize` work?Beginner