Scrivio Interview library
DesignAdvanced7 min read · updated 12 November 2026

Define a standard for liveness, readiness and startup probes for all Spring services on Kubernetes.

The standard gives each probe one job. Liveness checks only the application's internal state, with generous thresholds and never an external dependency. Readiness checks whether this pod can serve, including only the critical dependencies it truly needs, at a short interval. A startup probe covers slow starts so liveness never has to be loosened. All services serve probes the same way, either on the main port with add-additional-paths or on a management port, and the platform starter and Helm chart supply these settings as defaults.

Why this question is asked

When a company has dozens or hundreds of Spring services, every team inventing its own probe settings leads to a predictable mix of problems: some services restart in loops when the database blinks, some receive traffic before they are warm, and some never get restarted when they deadlock. A standard fixes this once. Interviewers ask this design question to see whether we know what each probe is for, how Spring Boot supports them, and how to roll a standard out so it is actually used. In this answer, we will recap the three probes, define the rule for each one with concrete numbers, decide on the port, and package the whole standard into a starter and a Helm chart.

1A Quick Recap of the Three Probes

Kubernetes runs probes against every container. The kubelet, the agent on each node, calls an HTTP path at a fixed interval (periodSeconds) and counts consecutive failures; after failureThreshold failures it acts. The three probes differ only in the action.

A liveness probe failure restarts the container. A readiness probe failure removes the pod from the Service's endpoints, so it gets no traffic until it passes again. A startup probe runs first, and while it has not yet succeeded, Kubernetes does not run the other two at all; if it never succeeds within its window, the container is restarted. Spring Boot backs these with two health groups, liveness and readiness, available at /actuator/health/liveness and /actuator/health/readiness, which it drives from its LivenessState and ReadinessState.

Step throughHow Kubernetes uses the three probes
  1. Container starts
  2. Startup probe passed within its window?
    YesBegin liveness and readiness checksNoRestart the container
  3. Liveness failing 3 times in a row?
    YesRestart the containerNoKeep running
  4. Readiness failing?
    YesRemove pod from Service endpointsNoSend traffic to the pod

4 steps in order. Play them, or step through them one at a time.

2Rule for Liveness: Internal State Only

Liveness answers one question: would a restart fix this process? That is true for a deadlock, a corrupted in-memory state, or an application that has published LivenessState.BROKEN because it detected an unrecoverable error. It is never true for a database outage, because a restarted pod finds the same broken database. So the standard says the liveness group contains only the livenessState indicator, and teams may not add dependency checks to it.

The thresholds are generous because a restart is expensive: it drops in-flight requests, empties caches and costs another JVM warm-up. A garbage collection pause of a few seconds or a short CPU spike must not kill a healthy pod. A reasonable default is a 10 second period, a 3 second timeout and a failure threshold of 3, so a pod is only restarted after about 30 seconds of continuous failure.

3Rule for Readiness: Can This Pod Serve?

Readiness answers whether this pod should get traffic right now. Boot already handles the main cases: it refuses traffic until startup runners finish and again as soon as shutdown begins. Beyond that, the standard allows a team to add a dependency only when the pod is truly useless without it, and only with a written reason in the service's configuration.

The catch is shared dependencies. If all pods depend on the same database and the database is in readiness, a database failover removes every pod at once and the Service has no endpoints. Callers then see connection failures instead of a clean error response. So the default readiness group contains readinessState only, and the standard warns that adding a shared dependency is an all or nothing switch. Readiness uses a short interval, 5 seconds with a threshold of 2, because removing a pod from traffic is cheap and reversible.

4Rule for Startup: Cover Slow Starts Without Loosening Liveness

Some Spring services take a minute or more to start, because of a large context, Flyway migrations or cache loading. Without a startup probe, teams raise initialDelaySeconds on liveness to avoid restarts during startup, which also slows down detection of real problems forever after. The startup probe solves this cleanly: it points at the liveness path, and only once it succeeds do the normal liveness rules apply.

The window is periodSeconds times failureThreshold. With a 5 second period and a threshold of 36, a service may take up to 180 seconds to start.

YAML
# Helm chart defaults (values.yaml), every service inherits these
probes:
startup:
path: /livez
periodSeconds: 5
failureThreshold: 36 # up to 180 s to start
liveness:
path: /livez
periodSeconds: 10
timeoutSeconds: 3
failureThreshold: 3 # about 30 s of failure before a restart
readiness:
path: /readyz
periodSeconds: 5
timeoutSeconds: 2
failureThreshold: 2 # out of rotation after about 10 s
# Rendered for the container:
# startupProbe: httpGet { path: /livez, port: http }
# livenessProbe: httpGet { path: /livez, port: http }
# readinessProbe: httpGet { path: /readyz, port: http }

5Choosing One Way to Serve the Probes

There are two reasonable options, and the standard should pick one for everybody, because consistency is what lets the Helm chart work for all services. The first option serves the probes on the main application port. With management.endpoint.health.probes.add-additional-paths=true, Boot exposes the liveness group at /livez and the readiness group at /readyz on the main server, even if the rest of Actuator lives elsewhere. The advantage is that a probe goes through the same web server, connector and thread pool as real traffic, so if the main server is stuck, readiness fails too.

The second option puts all of Actuator on a separate management port with management.server.port, which keeps actuator traffic off the public listener and makes network policies simple. The cost is that a probe on the management port can succeed while the main port is unable to accept requests. I would choose the main port with the additional paths for the probes, and keep the rest of Actuator on the management port for operators, so we get both accurate probes and a separate surface for sensitive endpoints.

Options for where probes are served
OptionProbe pathStrengthWeakness
Main port + additional paths/livez, /readyz on 8080Probe shares the real request pathProbe paths visible on main port
Management port only/actuator/health/... on 8081Actuator isolated from trafficCan pass while main port is stuck
Mixed per serviceVariesNoneHelm chart cannot be shared

6Shipping the Standard: Platform Starter and Helm Chart

A standard written in a document drifts within a year. A standard that is the default stays. So the Spring side lives in the company's platform starter, a small auto-configuration library every service already depends on, which contributes default properties. The Kubernetes side lives in the shared Helm chart or deployment template, which renders the probe definitions above from values.yaml.

Properties
# Defaults contributed by the platform starter (for example through an
# EnvironmentPostProcessor that adds a low-priority property source)
management.endpoint.health.probes.enabled=true
management.endpoint.health.probes.add-additional-paths=true
management.endpoint.health.group.liveness.include=livenessState
management.endpoint.health.group.readiness.include=readinessState
management.server.port=8081
server.shutdown=graceful
# A team that needs its own database in readiness overrides one line, with a reason:
# management.endpoint.health.group.readiness.include=readinessState,db

Because the starter's defaults have low priority, a team can still override a value in its own application.properties, but the override is visible in code review. Finally, I would add graceful shutdown and a short preStop sleep to the chart, so a pod keeps serving for a few seconds while load balancers notice that readiness has dropped.

7Follow-up questions

Why not put the database in liveness if the service cannot work without it?

Because a restart cannot fix the database. When the database fails over, every pod would be restarted at the same time, and they would then crash loop with growing back-off until long after the database is healthy again. Liveness must only cover what a restart repairs.

How do you handle a service that takes five minutes to start?

Raise the startup probe's failureThreshold for that service, for example to 60 with a 5 second period, and leave liveness at the standard values. I would also ask why it takes five minutes, since long starts make scaling and recovery slow.

8Conclusion

In this answer, we defined a probe standard where each probe has one job. Liveness covers internal state only and acts slowly; readiness covers the ability of this pod to serve, acts quickly and avoids shared dependencies unless there is a written reason; and a startup probe protects slow starts so liveness never has to be loosened. We chose to serve probes on the main port with add-additional-paths and keep the rest of Actuator on a management port, and we shipped the settings through the platform starter and the shared Helm chart so every service follows the standard by default.

What to say in the interviewAbout 80 seconds aloud

Open with

I would give each probe exactly one job. Liveness checks only the internal state, so the liveness group contains just livenessState and never the database or downstream services, because a restart cannot fix those and it causes restart storms.

Then, if they want more

Its thresholds are generous, something like a 10 second period and three failures, so a GC pause does not kill a healthy pod. Readiness asks whether this pod can serve.

By default it is just readinessState, which Boot already switches during startup and shutdown, and a team can add a critical dependency only with a written reason, knowing that a shared dependency there can remove every pod at once. Readiness runs every 5 seconds with two failures.

For slow services, a startup probe on the liveness path with a 180 second window covers the start without loosening liveness. All services serve probes the same way: I prefer the main port with add-additional-paths, so /livez and /readyz go through the same server as real traffic, while the rest of Actuator stays on a management port.

Then I ship it as defaults in the platform starter and the Helm chart, and report services that override them.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Spring Boot reference, Actuator
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Define a standard for liveness, readiness and startup probes for all Spring services on...": https://scrivio-interview-library.netlify.app/spring-boot/actuator/d7d47d47a0/