Skip to the page

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.

The notes

What you must know

  • Liveness: this process is broken, restart it. Readiness: do not send traffic right now. /actuator/health combines every indicator, including the database. Pointing liveness at it restarts every pod when the database is slow.
  • Use Boot's probe groups /actuator/health/liveness and /actuator/health/readiness (on by default in Boot 4). Liveness reflects only the app's own state. Add a startupProbe for 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/startup with BufferingApplicationStartup.
  • Warm-up after startup: run it on ApplicationReadyEvent in 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 health is exposed over HTTP by default. Never set management.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.settlement with {"configuredLevel": "DEBUG"}. Narrow it with merchantId in 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

  1. Pods restart before the app finishes starting. What do you do?
  2. What is the difference between liveness and readiness?
  3. A researcher downloads /actuator/heapdump. What do you do?
  4. The gateway returns 502s after each deploy. Why?
  5. 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 voice

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview