k8s - livenessProbe vs readinessProbe
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Understanding Liveness Probe vs Readiness Probe in Kubernetes
As organizations deploy applications at scale, Kubernetes (K8s) has become a go-to platform for container orchestration due to its robust management capabilities. Two critical features in Kubernetes that help maintain the health of applications are the livenessProbe and readinessProbe. Understanding the distinction between them is essential for ensuring that applications are both resilient and performant in a Kubernetes environment.
Probes Overview
Probes in Kubernetes are diagnostic checks performed on running containers to determine their health and status. These probes are part of a Pod specification and are crucial for maintaining application reliability and availability.
Liveness Probe
The liveness probe is responsible for ensuring that an application is alive. If a liveness probe fails, Kubernetes assumes that the container is unhealthy and restarts it.
- Purpose: To detect and remedy pod failures that render the application non-functional.
- Common Use-Cases:
- Application deadlock detection where the application is running but unable to progress.
- Critical application faults requiring a restart for recovery.
- Technical Implementation: A typical liveness probe can be implemented using HTTP, TCP, or as an
execcommand.
In this example, Kubernetes will check the /healthz endpoint on port 8080 every 10 seconds, starting 10 seconds after the container starts.
Readiness Probe
The readiness probe determines if a container is ready to accept traffic. If the probe fails, Kubernetes will remove the pod from service endpoints.
- Purpose: To ensure that traffic is only directed to pods capable of serving requests.
- Common Use-Cases:
- Applications that have a startup time before becoming fully operational.
- Services that depend on external systems or configurations.
- Technical Implementation: Similar to liveness probes, readiness probes can be specified using HTTP requests, TCP sockets, or executed commands.
Here, Kubernetes checks if the application is ready to serve on port 3306, with a slight delay after starting the pod.
Comparison Table
| Aspect | Liveness Probe | Readiness Probe |
| Purpose | Ensures container is running and healthy | Ensures container is ready to serve traffic |
| Action on Failure | Restarts the container | Removes pod from the list of service endpoints |
| Use-Case | Recover non-functioning applications | Avoid routing to non-ready applications |
| Triggers | Issues like deadlocks, critical faults | Application initialization, dependency readiness |
| Frequency | User-defined; periodic checks | User-defined; periodic checks |
Additional Considerations
- Customization Options: Both probes can be customized with
initialDelaySeconds,periodSeconds,timeoutSeconds,successThreshold, andfailureThresholdto fine-tune their behavior according to the application's demands. - Simultaneous Use: It's possible, and often advantageous, to use both liveness and readiness probes simultaneously in a deployment to cover all bases for application monitoring and management.
- Impact on Performance: Misconfigured probes can lead to unnecessary restarts or service disruptions. For instance, if a readiness probe is too aggressive, it might not allow sufficient time for an application to become ready, leading to a quasi-DDoS scenario.
- Debugging Probes: When debugging probe-related issues, leverage Kubernetes events and logs. The
kubectl describecommand can provide insights into the last probe checks' results.
Conclusion
In summary, Kubernetes' liveness and readiness probes serve distinct but complementary purposes. Correctly configuring and utilizing these probes enhances fault tolerance and ensures that applications can dynamically adapt to changing states without manual intervention. Mastering these probes is a critical skill for any Kubernetes practitioner aiming to deploy resilient and scalable applications.
Related reading
- K8S Cronjob PVC cleanup
- K8S Error running load balancer syncing routine
- K8S Failed to pull image from local repo
- K8s how to install charts from the Helm Hub
- Kafka-docker container scaling failed for wurstmeister with error as advertised listeners are already registered by broker 1001
- Kafka - Docker - Error when sending message from Host to Container (Batch Expired)
- K8s NodePort service is “unreachable by IP” only on 2/4 slaves in the cluster
- K8S Read config map via go API

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.