Video in progress
What is a startup probe, and how does it help a slow-starting Spring Boot application?
Until the startup probe succeeds, the liveness and readiness checks do not start at all. That lets you keep liveness short and strict while giving the app a long time to start.
📖 Answer
The problem: the app takes 90 seconds to come up (a big context, Flyway, cache warm-up). If you tune liveness for that with initialDelaySeconds: 120, then when the app freezes later you notice it 2 minutes late. If you keep it short, the app is killed before it has finished starting.
A startup probe separates these two requirements:
startupProbe:
httpGet: { path: /actuator/health/liveness, port: 8080 }
periodSeconds: 5
failureThreshold: 36 # waits up to 36 * 5 = 3 minutes
livenessProbe:
httpGet: { path: /actuator/health/liveness, port: 8080 }
periodSeconds: 10
failureThreshold: 3 # after startup, notices within 30 seconds
Once the startup probe has passed once, it is done, and liveness takes over the rest of the checking.
But this is a painkiller, not a cure. If the app takes three minutes to come up, autoscaling also reacts three minutes late. Measure the startup time: spring.main.lazy-initialization (carefully), disabling unneeded auto-configurations, CDS (class data sharing), or the AOT/CDS support in Spring Boot 3.3+ can cut a lot of time.
Sign up to mark studied questions and save your progress.