Skip to content

    System Design

    Health Checks: Liveness, Readiness and Startup Probes

    Liveness, readiness and startup probes answer three different questions. Learn what each should check, using Spring Boot Actuator groups and Kubernetes rules.

    By Published 11 min read

    Share

    Focused lessonbeginnerSpring Boot labBackend System Design

    Before this: Observability and SLOs

    What you'll learn: By the end of this lesson you will be able to say what a liveness, a readiness and a startup probe each ask and what the platform does when each fails, decide which checks belong in which probe, explain why a liveness probe that checks a database can turn one outage into a fleet-wide restart, and configure Spring Boot Actuator health groups so that a failing dependency changes readiness but not liveness.

    A restaurant has two signals. A "closed" sign on the door means: do not send customers in now; the kitchen is fine and will reopen. A call to the fire brigade means: something is wrong inside that only a drastic step will fix. Hanging the "closed" sign when the supplier is late is sensible. Calling the fire brigade because the supplier is late is not.

    A health check is an endpoint a platform calls to learn whether an instance should get traffic or be restarted. It is not a monitoring dashboard and not a place to find out everything that is wrong; it feeds a decision that a machine takes by itself. Observability and SLOs cover how people watch a system; this lesson covers how the platform acts on it, and it pairs with graceful degradation and failure handling end to end, which decide what a service does while a dependency is down.

    Verified against the Kubernetes and Spring Boot documentation on 2026-12-01. The Kubernetes behaviour described comes from those pages; the lab runs Spring Boot 4.1.2 with MockMvc, so it shows what the application answers, not what a kubelet does.

    The core idea

    Three probes, three questions, three actions. Started yet? Stuck for good? Able to take work right now? A failed answer to each leads to a different action, and mixing the questions is the usual mistake.

    • Minimal example: two probe URLs on one Spring Boot application, both answering 200 (situation 1 of the lab).
    • Realistic example: ShopStream's checkout service, which needs Payments but only wants Recommendations (see "In practice").
    • Failure example: a liveness probe that checks the database, so a database outage restarts every instance.

    What Kubernetes does with each probe

    The Kubernetes documentation defines the three probes this way:

    Probe The question When it fails When it runs
    Startup Has the application started? The kubelet kills the container, subject to its restart policy Only at startup; while it is configured, the other two do not run until it succeeds
    Liveness When should the container be restarted? After more failures than the configured tolerance, the kubelet restarts the container Periodically, for the whole life
    Readiness Is the container ready to accept traffic? The EndpointSlice controller removes the Pod's IP address from the EndpointSlices of all matching Services Periodically, for the whole life

    For an HTTP probe, any status from 200 up to but not including 400 is success and anything else is failure. Readiness is useful at startup (the page lists establishing connections, loading files and warming caches) and later, for example when recovering from temporary faults or overloads. Liveness probes do not wait for readiness; to delay one, use initialDelaySeconds or a startup probe.

    stateDiagram-v2 accTitle: What each probe failure causes accDescr: A container starts. While a startup probe is configured the other probes wait. After startup, a failing readiness probe removes the Pod from Service endpoints and a passing one adds it back; a liveness probe failing past its tolerance makes the kubelet restart the container. [*] --> Starting Starting --> Running: startup probe passes Running --> NotReady: readiness fails NotReady --> Running: readiness passes Running --> Restarting: liveness fails past tolerance NotReady --> Restarting: liveness fails past tolerance Restarting --> Starting: container restarted

    Figure 1. Two exits, very different costs. How to read this: readiness failing is a reversible detour; the instance stays up and comes back by itself. Liveness failing is a restart, with all the cold caches and lost in-memory state that implies.

    Which checks belong where

    The Kubernetes documentation warns that liveness probes "must be configured carefully to ensure that they truly indicate unrecoverable application failure, for example a deadlock", and that incorrect ones can cause cascading failures: restarts under high load, failed client requests and more work for the remaining Pods. Spring Boot's documentation says the same about dependencies: the liveness state "should not be based on external checks", because a failing external system, such as a database, Web API or external cache, would trigger massive restarts and cascading failures across the platform.

    For a service with strict dependencies, Kubernetes suggests both probes: liveness passes when the application itself is healthy, and readiness additionally checks that each required back-end is available. Spring Boot adds a refinement: some external systems are not shared by application instances and may belong in readiness, while a system that is not essential, because the application has circuit breakers and fallbacks, definitely should not.

    Check Liveness Readiness Why
    The process can answer at all Yes Yes The cheapest signal of "not wedged"
    Internal state the app cannot recover from (a broken local structure) Yes No A restart is the right repair; liveness covers it
    A required dependency (Payments) is reachable No Yes Restarting does not fix Payments; stopping traffic avoids errors
    An optional dependency with a fallback No No The service still works; a fallback exists
    Warm-up finished (caches, connections) No Yes Not ready is temporary
    "I am too busy for more traffic" No Yes Spring Boot lists this as a reason for readiness to fail
    flowchart TD accTitle: Deciding where a health check belongs accDescr: For one check, ask whether a restart would fix the failure. If yes, put it in liveness. If no, ask whether the service cannot do its job without it. If yes, put it in readiness. If the service still works, use a fallback and keep it out of both probes. Q["A failing check:
    would a restart fix it?"] -->|yes| L["Liveness
    (and readiness)"] Q -->|no| R{"Can the service do
    its job without it?"} R -->|no| RD["Readiness only"] R -->|yes| FB["Neither probe:
    degrade with a fallback"]

    Figure 2. One question per check. How to read this: start with the repair. A restart fixes a wedged process, never someone else's database, so outside systems land in readiness or nowhere.

    Spring Boot Actuator health groups

    Spring Boot tracks two availability states, liveness (CORRECT or BROKEN) and readiness (ACCEPTING_TRAFFIC or REFUSING_TRAFFIC). The documentation says the application is live as soon as the context has refreshed, and ready once application and command-line runners have been called. Actuator exposes the states as health groups at /actuator/health/liveness and /actuator/health/readiness, and by default adds no other health indicators to them. A group is built with management.endpoint.health.group.<name>.include, and management.endpoint.health.probes.add-additional-paths=true serves the two probes on the main port at /livez and /readyz. The HTTP status reflects the health status: by default DOWN and OUT_OF_SERVICE give 503, and UP gives 200, which a kubelet's HTTP probe reads as failure and success.

    The documentation also says a startup probe is not necessarily needed here, because the readiness probe fails until all startup tasks are done. Kubernetes' own guidance is to use one for containers that take a long time to start, with a failureThreshold high enough to cover startup, so liveness can keep its defaults.

    Build it

    The lab is examples/spring-labs/labs/health-probes (Spring Boot 4.1.2, Actuator, MockMvc; no server port, no Docker, no Kubernetes). The reference pages read for this lesson link their API pages for a newer release, 4.2.0; the properties used below are the ones those pages name. Two fake outside systems have health indicators named payments and recommendations. The configuration:

    management.endpoint.health.probes.enabled=true
    management.endpoint.health.show-components=always
    management.endpoint.health.group.readiness.include=readinessState,payments
    management.endpoint.health.group.dependencies.include=payments,recommendations
    management.endpoint.health.group.badliveness.include=livenessState,payments

    Liveness stays at its default. Readiness adds payments, which the service cannot work without, and leaves out recommendations, which has a fallback. dependencies is what a dashboard would read. badliveness is wrong on purpose, to show the hazard.

    Probes, health groups and dependenciesKubelet to Actuator (liveness, readiness); Actuator to Payments (readiness only); Actuator to Recommender (dependencies group)Kubelet: calls probesKubeletcalls probesActuator: health groupsActuatorhealth groupsPayments: requiredPaymentsrequiredRecommender: optionalRecommenderoptionalliveness, readinessreadiness onlydependencies group

    Figure 3. Who is asked what. How to read this: the kubelet asks two questions; only readiness reaches Payments. Recommendations is visible to people through its own group but to no probe.

    The report drives the application through seven situations and records the status and body each URL returns.

    Expected output, captured from a real run (MockMvc against the Actuator endpoints, Spring Boot 4.1.2):

    1. Everything healthy
      GET /actuator/health/liveness        -> 200  {"status":"UP"}
      GET /actuator/health/readiness       -> 200  {"components":{"payments":{"status":"UP"},"readinessState":{"status":"UP"}},"status":"UP"}
    
    2. payments (required) goes down
      GET /actuator/health/liveness        -> 200  {"status":"UP"}
      GET /actuator/health/readiness       -> 503  {"components":{"payments":{"status":"DOWN"},"readinessState":{"status":"UP"}},"status":"DOWN"}
      GET /actuator/health/dependencies    -> 503  {"components":{"payments":{"status":"DOWN"},"recommendations":{"status":"UP"}},"status":"DOWN"}
    
    3. payments comes back, nothing restarted
      GET /actuator/health/readiness       -> 200  {"components":{"payments":{"status":"UP"},"readinessState":{"status":"UP"}},"status":"UP"}
    
    4. recommendations (optional, has a fallback) goes down
      GET /actuator/health/readiness       -> 200  {"components":{"payments":{"status":"UP"},"readinessState":{"status":"UP"}},"status":"UP"}
      GET /actuator/health/dependencies    -> 503  {"components":{"payments":{"status":"UP"},"recommendations":{"status":"DOWN"}},"status":"DOWN"}
    
    5. the application decides it is too busy for more traffic
      GET /actuator/health/liveness        -> 200  {"status":"UP"}
      GET /actuator/health/readiness       -> 503  {"components":{"payments":{"status":"UP"},"readinessState":{"status":"OUT_OF_SERVICE"}},"status":"OUT_OF_SERVICE"}
    
    6. a liveness group that checks payments (the wrong design), payments down
      GET /actuator/health/badliveness     -> 503  {"components":{"livenessState":{"status":"UP"},"payments":{"status":"DOWN"}},"status":"DOWN"}
    
    7. the application finds its own state unrecoverable
      GET /actuator/health/liveness        -> 503  {"status":"DOWN"}
      GET /actuator/health/readiness       -> 200  {"components":{"payments":{"status":"UP"},"readinessState":{"status":"UP"}},"status":"UP"}

    How to read it:

    • Situation 2. Payments down makes readiness 503 and leaves liveness at 200: traffic stops, nobody is restarted. Situation 3: when Payments returns, readiness is 200 again without a restart.
    • Situation 4. The optional dependency down leaves readiness at 200, while the dependencies group is 503: people see it, the platform does not act.
    • Situation 5. The application can refuse traffic by itself (OUT_OF_SERVICE, also 503) while liveness stays 200.
    • Situation 6. The wrong design: the group that mixes in Payments returns 503 when Payments is down. Pointed at by a liveness probe, a kubelet would read 503 as failure (200 up to 399 is success) and restart the container once failures pass the tolerance, for every instance at once. The lab shows only the status; the restart is what the Kubernetes documentation describes.
    • Situation 7. An application that publishes LivenessState.BROKEN fails liveness; this is the one case where a restart is the right repair.
    sequenceDiagram accTitle: A required dependency fails and recovers accDescr: The kubelet polls the readiness URL. While Payments is up the application answers 200. When Payments fails the application answers 503 and the platform stops sending traffic to that Pod. The liveness URL keeps answering 200, so nothing is restarted. When Payments returns, readiness answers 200 again and traffic resumes. participant K as Kubelet participant A as Application participant P as Payments K->>A: GET readiness A->>P: check P-->>A: up A-->>K: 200 Note over P: Payments fails K->>A: GET readiness A->>P: check P--xA: no answer A-->>K: 503 (Pod leaves Service endpoints) K->>A: GET liveness A-->>K: 200 (no restart) Note over P: Payments returns K->>A: GET readiness A-->>K: 200 (traffic resumes)

    Figure 4. The sequence behind situations 2 and 3. How to read this: two URLs, two outcomes. The readiness answer changes and back again; the liveness answer never does. The lab reproduces the application's side of this exchange; what the kubelet does with each answer is taken from the Kubernetes documentation.

    Run it from examples/spring-labs: ./gradlew :labs:health-probes:test. The tests assert each claim and compare the report with golden/health-probes.txt.

    Trade-offs

    Choice Gain Cost Wrong when
    Required dependency in readiness No traffic to an instance that will fail If the dependency is shared, every instance goes unready together Payments being down should still allow browsing (split the service or degrade)
    Liveness is only the process No restart storms A hung dependency call can wedge threads and go unseen You need a separate internal self-check
    Startup probe Slow starts do not trip liveness One more setting to tune Startup is fast and readiness alone is enough
    Expensive health endpoint Richer signal Probes add load and slow answers fail The check calls five systems every few seconds

    In practice: ShopStream checkout and its dependencies

    This is a realistic scenario, not a case history.

    This is an educational scenario on ShopStream, the course's grocery marketplace; nothing in it describes a real company. Every number other than the shared ones is illustrative.

    The situation

    The checkout service needs Payments to take an order and calls Recommendations to show "you may also like". Today one /health endpoint checks both plus the database, and the platform uses it for liveness and readiness. During a short Payments incident, every instance fails /health and gets restarted, and the restarts take away the capacity needed to serve the carts people were still filling.

    Starting architecture

    One endpoint, both probes, three outside checks: a Payments failure is treated as "this instance is broken".

    Options considered

    Option Behaviour Cost Risk
    A. Keep one endpoint Simple None Outage turns into restarts
    B. Liveness = process only; readiness = Payments plus warm-up; Recommendations in neither Restart only for real wedges Two groups, a startup probe, a short test Readiness for a shared dependency removes all instances at once
    C. Remove health checks No false alarms No automatic response at all Hung instances stay in rotation

    The decision

    Option B. Liveness is the application's own state. Readiness is warm-up plus Payments, because without Payments checkout cannot succeed. Recommendations stays out of both probes, because the page has a fallback. The team accepts the cost named in the table: Payments is shared by every instance, so a Payments outage makes all of them unready together. Browsing is served by a different service that does not need Payments, so shoppers can still look around (see graceful degradation).

    Rollout and verification

    Ship the new groups next to the old endpoint and point nothing at them. Compare, in a test environment, what each answers while Payments is made to fail (the lab's situations 2 to 4). Then move readiness first, liveness second. Evidence: restarts per hour during a Payments failure (expected to fall to zero), the number of ready instances, and the error rate on checkout.

    The 2 a.m. failure

    During a Payments incident every checkout instance turns unready at the same moment, as designed, and the checkout page returns errors for everyone, including shoppers who only wanted to edit their cart, which lives in the same service. The alert reads "checkout ready instances: 0". First checks: the readiness response body (it names payments as DOWN), the Payments status page, and which endpoints still work. Mitigation: while Payments is down, a flag removes payments from the readiness group so instances accept traffic and only the payment step returns its clear "try again soon" message. Follow-ups: move cart editing to a service that does not need Payments, alert on "ready instances below a floor" before it reaches zero, and rehearse this failure as an experiment (see chaos engineering).

    Architect's notes

    • Ask what repair a failure needs. A restart fixes a wedged process, nothing else.
    • Keep liveness boring and cheap. The process answers; internal state is sane.
    • Put required dependencies in readiness, optional ones nowhere.
    • Test the probes' answers during a dependency failure, not only when everything is up.

    Common mistakes

    • Liveness that calls the database. One outage becomes a fleet restart.
    • Readiness with every dependency in it. The service goes unready for a failure it could have absorbed.
    • One endpoint for every probe. Different questions, different answers.
    • Never testing the not-ready path. It is the path that matters during an incident.

    Key takeaways

    • Startup, liveness and readiness ask different questions and cause different actions.
    • Failing liveness restarts the container; failing readiness only stops traffic.
    • External systems do not belong in liveness; required ones belong in readiness.
    • Spring Boot Actuator exposes liveness and readiness as health groups you configure with include.
    • A failing dependency should change readiness, not liveness, and recover without a restart.
    • Test the probe answers while a dependency is failing.

    Practice exercises

    Exercise 1 (30 min). For your own service, list its checks and place each in liveness, readiness or neither, with the reason.

    Exercise 2 (45 min). In the lab, add a search dependency that is required and one that is optional. Predict the probe answers before you run the report.

    Official documentation

    Ask about this article

    Get answers grounded in this post. AI-generated — based on this article, and may be imperfect.

    Scaled AI Weekly

    Enjoyed this? Get more like it every Monday.

    Real architecture decisions, LLMOps patterns that survive production, and engineering leadership advice — from 12+ years of building at enterprise scale. Free. No spam. Unsubscribe anytime.

    Get new articles by email

    Free. We email a confirmation link first, and you can unsubscribe from any email.

    Join engineers building production AI systems

    Comments