Spring in production · mid
Probes, startup, Actuator and logging
Liveness and readiness answer different questions. Actuator endpoints are powerful and must be protected. Log levels can change at runtime.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Liveness: this process is broken, restart it. Readiness: do not send traffic right now.
/actuator/healthcombines every indicator, including the database. Pointing liveness at it restarts every pod when the database is slow. - Use Boot's probe groups
/actuator/health/livenessand/actuator/health/readiness(on by default in Boot 4). Liveness reflects only the app's own state. Add astartupProbefor slow starts. - A pod that takes 3 minutes to start is killed if the liveness probe starts early. Find the slow part with startup timestamps or
/actuator/startupwithBufferingApplicationStartup. - Warm-up after startup: run it on
ApplicationReadyEventin the background and keep readiness down until it is done. Do not load millions of rows in@PostConstruct. - Heap dump endpoint open to the internet: it holds passwords, keys and customer data. Block
/actuator/**at the gateway, rotate secrets, treat it as a breach. - Only
healthis exposed over HTTP by default. Never setmanagement.endpoints.web.exposure.include=*in production. Use a separate management port. - 502s after every deploy: the pod is still listed as an endpoint for a few seconds after SIGTERM. Use graceful shutdown and a short preStop delay. A steady trickle can be a keep-alive mismatch between the gateway and Tomcat.
- Change log level without restart:
POST /actuator/loggers/com.shop.settlementwith{"configuredLevel": "DEBUG"}. Narrow it withmerchantIdin the MDC and a Logback turbo filter. Reset on time. Never log card numbers, Aadhaar numbers, OTPs, passwords, tokens or full request bodies.
The red pen
Common traps: mistake → fix
Mistake: Liveness should check the database
Fix: a slow database would restart every pod.
Mistake: Actuator is safe because it is internal
Fix: a wrong exposure setting makes it public.
Mistake: Debug logging needs a restart
Fix: the loggers endpoint changes levels live.
Easy to hard
Questions interviewers ask, easy to hard
- Pods restart before the app finishes starting. What do you do?
- What is the difference between liveness and readiness?
- A researcher downloads /actuator/heapdump. What do you do?
- The gateway returns 502s after each deploy. Why?
- How do you get debug logs for one merchant without a restart?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.