Kubernetes Probes: Liveness vs Readiness vs Startup for Spring Boot
Fast recall
Quick revision
Core answer
Whether you understand different failure behaviors and when each probe type is needed
Omitting startup probe for Spring Boot — liveness fires during JVM startup, container restarts, loop repeats forever; OR putting DB checks in liveness so a brief DB outage restarts every pod simultaneously
Explain Spring Boot `/actuator/health/liveness` vs `/readiness` split, the restart-loop scenario, how ApplicationAvailability API emits signals, and why dependency checks belong in readiness not liveness
Interview-ready guide
Interview answer
Kubernetes uses three probe types to determine container health, and they exist for different failure modes. Misconfiguring them — particularly confusing liveness with readiness — causes either cascading restarts that bring down a healthy application or traffic being sent to containers that are not ready.
Liveness — is the JVM responding?
- A failed liveness check restarts the container; it is the circuit breaker for deadlocked, hung, or permanently broken processes that cannot recover without a restart.
- Use the Actuator liveness endpoint:
GET /actuator/health/liveness— Spring Boot 2.3+ reportsUPwhen the context is healthy and not broken; it does not check database connectivity because a database outage should not restart healthy Pods. - Set a generous window via startup probe rather than
initialDelaySeconds— a liveness probe that fires during Spring Boot's init triggers a restart loop.
Readiness — is the app ready for traffic?
- A failed readiness check removes the Pod from the Service's Endpoints; traffic stops routing to it, but the Pod keeps running and can recover; this is the correct response to temporary overload or slow downstream dependencies.
- Use
GET /actuator/health/readiness— Spring Boot's readiness state starts asREFUSING_TRAFFICduring init and transitions toACCEPTING_TRAFFIConly afterApplicationReadyEventfires, including database connection pool establishment. - Set readiness
failureThresholdlower than liveness — failing quickly removes a pod from rotation; liveness requires more failures before triggering restart to avoid restarting a slow-but-recovering pod.
Startup — protecting slow-starting JVMs
- The startup probe is the correct solution for slow Spring Boot apps; while it has not succeeded, liveness and readiness checks are suspended — this prevents the restart loop during initialization.
failureThreshold: 30withperiodSeconds: 10gives the app 5 minutes to start; after startup succeeds, liveness and readiness take over with normal thresholds.- Without a startup probe you must inflate liveness
initialDelaySeconds— that delay also applies after real restarts, making recovery slower than necessary.
Anti-patterns to avoid
- Dependency checks in liveness turn a partial outage into a total one — a 30-second DB failover restarts every pod across every replica simultaneously.
- Exec probes on memory-tight JVM pods are expensive — they fork processes inside the container; prefer HTTP probes unless you must shell out.
Kubernetes Probes: Liveness vs Readiness vs Startup for Spring Boot
Direct Answer
Liveness answers 'is the process stuck?' — failure restarts the container. Readiness answers 'can this pod serve traffic now?' — failure removes it from Service endpoints without restart. Startup answers 'has the app finished initializing?' — while failing, both liveness and readiness are suspended. Use all three for Spring Boot: startup covers slow boot, readiness tracks dependency health, liveness catches only unrecoverable deadlocks.
Common Mistakes & Pitfalls
Omitting startup probe for Spring Boot — liveness fires during JVM startup, container restarts, loop repeats forever; OR putting DB checks in liveness so a brief DB outage restarts every pod simultaneously
Check your understanding
Answer these without looking back at the article.
- What happens to in-flight requests when a pod fails its readiness probe?
- How does Spring Boot's ApplicationAvailability API integrate with Kubernetes probes?
- When would you NOT configure a liveness probe at all?
- Why are exec probes more expensive than HTTP probes in a JVM container?
Related interview prep categories
2Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.