Quick revision
The short answer
/healthcheck runs the database check, so a short database blip makes every pod report unhealthy at once, and because the liveness probe uses it, Kubernetes restarts them all, turning a few seconds of database trouble into a full outage. Liveness should test only that the process works, for example the admin /ping endpoint, while readiness may include critical dependencies so traffic pauses without restarts. The dropwizard-health module adds scheduled, critical and non-critical checks with a separate readiness answer, and every check needs a timeout.
What to remember
In this answer, we saw that pointing liveness at /healthcheck makes every pod fail together when the database blips, and Kubernetes restarts them all, which cannot fix the database and makes the outage worse. Liveness should check only the process, for example /ping, readiness may include critical dependencies, and a startup probe protects slow starts. Dropwizard's health module adds scheduled checks, critical and non-critical checks and separate readiness answers, and short timeouts keep a hanging dependency from hanging the probe.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
/healthcheck runs the database check, so a short database blip makes every pod report unhealthy at once, and because the liveness probe uses it, Kubernetes restarts them all, turning a few seconds of database trouble into a full outage. Liveness should test only that the process works, for example the admin /ping endpoint, while readiness may include critical dependencies so traffic pauses without restarts. The dropwizard-health module adds scheduled, critical and non-critical checks with a separate readiness answer, and every check needs a timeout.
Why this question is asked
Kubernetes probes look like configuration detail, but a wrong probe can make the platform attack its own service. This scenario is a classic: the database hiccups for ten seconds, and minutes later every pod is restarting, caches are cold, and the database is hit by a storm of reconnecting pools. Interviewers ask it because it tests whether we know what liveness and readiness mean and what each one makes Kubernetes do. In this answer, we will recap the two probes, trace why the current setup fails, set up probes correctly, use Dropwizard's health module, and protect checks with timeouts.
1A Quick Recap of Liveness and Readiness
Kubernetes calls probes on each container. A liveness probe answers the question: is this process broken beyond repair? If it fails a number of times in a row (failureThreshold, 3 by default), the kubelet kills the container and starts a new one. A readiness probe answers a different question: should this pod receive traffic right now? If it fails, Kubernetes removes the pod from the Service's endpoints, so no new requests reach it, but the container keeps running. When readiness passes again, traffic returns.
So the two probes have very different consequences. A failed readiness probe is gentle and reversible. A failed liveness probe is drastic: it throws away the JVM, its warm JIT-compiled code, its caches and its connection pools.
2Why Every Pod Restarts
The current setup points the liveness probe at Dropwizard's /healthcheck. That endpoint runs every registered check, including the database check, and answers 500 if any is unhealthy.
6 messages in order. Play them, or step through them one at a time.
The same probe fails on every pod at the same time, so every pod is restarted.
Notice that the database problem is the same for every pod, so every pod fails the probe at the same moment. A restart cannot fix the database, so it achieves nothing except losing capacity. Worse, the pods then restart together and open their full connection pools against a database that just recovered, which can knock it over again. The probe has turned a dependency failure, which should cause degraded responses, into a self-inflicted outage.
3Setting Up the Probes Correctly
Liveness should check only things a restart can fix: that the JVM is running, the admin connector answers, and the process is not deadlocked. The admin /ping endpoint is a good fit; it returns pong without touching any dependency. Readiness can include the dependencies the service cannot work without, so that while the database is down the pod stops receiving traffic, and callers get a fast failure from the Service rather than slow errors from the pod.
There is still a judgement call. If every pod becomes not ready together, the Service has no endpoints and callers get connection errors anyway. That is usually acceptable, because nothing could have served them, but some teams prefer to keep pods ready and let requests fail fast inside the service with a clear 503. What matters most is that the liveness probe never depends on something outside the pod.
4Using Dropwizard's Health Module
Classic /healthcheck runs all checks on each request and has one answer for everything. The dropwizard-health module, part of Dropwizard core in recent versions, improves on that. Each check is scheduled in the background at its own interval, and the endpoint returns the latest state immediately. Each check is marked critical or non-critical: only critical checks make the service unhealthy, while non-critical ones are reported but do not flip the result. Checks can also be typed as alive or ready, and the endpoint can answer separately for each type, which maps directly onto liveness and readiness probes.
The module also uses thresholds, so one failed run does not flip the state; for example a check must fail three times in a row before it counts as down and succeed twice to count as up again. And on shutdown it can turn readiness off first and wait briefly, so Kubernetes stops sending traffic before Jetty stops accepting it. Configuration names, the endpoint path and the query parameter differ between versions, so check your version's documentation.
5Timeouts So a Hanging Dependency Cannot Hang the Probe
A probe has its own timeout, 1 second by default and 2 seconds in our configuration. If a check waits 30 seconds on a database that accepts connections but never answers, the endpoint misses that deadline and the probe fails, even for liveness if the check is on the liveness path. Each check therefore needs a timeout shorter than the probe's, for example a 1 second query timeout on the SELECT 1.
Scheduled checks help here too, because the endpoint no longer waits for checks to run at all: it reads the last result from memory, so it always answers in milliseconds. A hung dependency then shows up as a check that has been failing, not as a probe that times out.
6Follow-up questions
Should liveness include the deadlock check?
It can, because a deadlocked JVM is one of the few states a restart actually fixes. But it should be the only check on the liveness path, and it should be cheap. Many teams keep liveness on /ping and alert on the deadlock check separately, which avoids surprises; either choice is reasonable as long as no external dependency is involved.
What is a startup probe for?
A JVM service may need 20 or 60 seconds to start, warm up and run migrations. Without a startup probe, the liveness probe could kill it before it finishes. The startup probe runs first, with a generous total time, and liveness and readiness only begin once it succeeds. That lets liveness stay strict without punishing slow starts.
How would you test that the probes behave correctly?
In a staging cluster, block the database with a network policy or stop it for 30 seconds while traffic runs. The expected result is that pods become not ready, the restart count stays at zero, and traffic resumes within a few seconds of recovery. Running this fault injection after every probe change catches the mistake before production does.
7Conclusion
In this answer, we saw that pointing liveness at /healthcheck makes every pod fail together when the database blips, and Kubernetes restarts them all, which cannot fix the database and makes the outage worse. Liveness should check only the process, for example /ping, readiness may include critical dependencies, and a startup probe protects slow starts. Dropwizard's health module adds scheduled checks, critical and non-critical checks and separate readiness answers, and short timeouts keep a hanging dependency from hanging the probe.
Open with
The problem is that /healthcheck runs the database check, and the liveness probe uses it. When the database blips, every pod fails at the same moment, and after three failures the kubelet restarts all of them.
Then, if they want more
A restart can't fix a database, so we just lose all capacity, and then every pod reconnects at once with a full pool, which can knock the database over again. I'd fix it by separating the probes. Liveness only answers whether the process itself is broken, so I'd point it at the admin /ping endpoint, which touches no dependencies.
Readiness can include critical dependencies like the database, so pods stop getting traffic while it's down but keep running, and traffic comes back as soon as it recovers. I'd add a startup probe so slow JVM starts aren't killed.
In Dropwizard I'd use the health module: checks run on a schedule, they're marked critical or non-critical, typed as alive or ready, with failure and success thresholds, and the endpoint answers readiness separately.
I'd also give every check a timeout shorter than the probe timeout, and I'd test the whole thing by blocking the database in staging and confirming no restarts.
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 official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
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 "Kubernetes restarts all pods of a Dropwizard service whenever the database is briefly...": https://scrivio-interview-library.netlify.app/java/dropwizard/b171defd1f/