Health and readiness endpoints with Actuator
40 min · Advanced
A platform asks a running app two different questions: "are you broken beyond repair?" and "may I send you requests right now?". Answering them separately, with a liveness and a readiness probe, is what lets the platform restart a stuck app without also restarting a healthy one that is just busy starting up or shutting down.
Topics in this lesson
- Liveness vs readiness: restart me, or do not send me traffic
- Probes in Actuator: /liveness and /readiness
- Exposure and security: show only what is safe
- A probe server you can run: ready only after start-up
- Wiring probes into the platform and Compose
Key points
- Liveness failing means restart; readiness failing means no traffic. Never put the database in liveness.
/actuator/health/livenessand/readinesscome from Boot's availability states; adddbto the readiness group.- Expose only health and info,
show-details: when-authorizedwithroles: ADMIN, or move Actuator to a private management port. - Point the platform and Compose health checks at readiness, with a start period for Spring Boot to start.
Interview questions this lesson answers
- What is the difference between a liveness and a readiness probe?
- Why should the database check not be in the liveness probe?
- How does Spring Boot know when the app is ready?
- Which Actuator endpoints do you expose in production, and why?
- What happens to in-flight requests when your container is stopped?
- Which path do you give the platform as the health check?
- Does Docker restart an unhealthy container?
Sign in to continue this lesson
Create an account to read every lesson, practise with the exercises and keep track of your progress.