Skip to main content
← PROBLEMS / PRODUCTION-DEBUGGING
An end-to-end domain learning journey

Designing Safe Liveness
& Readiness Probes.

Separating /livez (dedicated management port, zero downstream DB checks, startupProbe for 45s JVM boot) from /readyz (DB pool + load shedding) prevents brief DB stalls from triggering a cluster-wide kubelet restart storm.
Start the journey5 stages
FIRST PRINCIPLES. PRODUCTION SCALE.
The idea to keep with you

When `/actuator/health` is wired to both `livenessProbe` and `readinessProbe` (`timeoutSeconds, never put downstream DB/Redis checks in livenessProbe, isolate management endpoints on a separate thread pool/port, and use startupProbe for slow JVM cold starts.

TL;DR30-second simplified summary
▾

Core Mechanics: When /actuator/health is wired to both livenessProbe and readinessProbe (timeoutSeconds: 1, periodSeconds: 5, failureThreshold: 3) on 24 Spring Boot pods (200 Tomcat threads, 20 HikariCP DB connections), a brief.

Visual & Structural Flow: Depicts 4s Postgres Lock: Coupled Liveness Death Spiral vs. Isolated /readyz (Kubelet -> Mgmt Port :8081 -> Tomcat :8080 -> Postgres); Startup (75s budget) -> Live & Ready <-> NotReady (DB Stall) (STARTING -> READY -> NOT_READY -> RESTART).

Trade-Offs & Production: Simply bumping timeoutSeconds from 1 s to 5 s on /actuator/health leaves the core flaw intact: Shared Thread Pool: If all 200 Tomcat threads are blocked on Postgres. Proper startupProbe / livenessProbe / readinessProbe separation is mandatory for resilient K8s workloads: JVM & Python ML Services: Preventing CrashLoopBackOff during 30–90 s model or Spring context loading.

Failure Modes & Application: Proper startupProbe / livenessProbe / readinessProbe separation is mandatory for resilient K8s workloads: JVM & Python ML Services: Preventing CrashLoopBackOff during 30–90 s model or Spring context loading.

Full walkthrough · 5 stages
01
STAGE 01 · WHY IT MATTERSL4 · FUNDAMENTALS

Why probe separation prevents cascading Kubernetes outages.

Why this matters: The mechanism: understand how Why probe separation prevents cascading Kubernetes outages works from first principles.

Think of Why probe separation prevents cascading Kubernetes outages as the intuition layer for Designing Safe Liveness & Readiness Probes: The mechanism: understand how Why probe separation prevents cascading Kubernetes outages works from first principles.

When /actuator/health is wired to both livenessProbe and readinessProbe (timeoutSeconds: 1, periodSeconds: 5, failureThreshold: 3) on 24 Spring Boot pods (200 Tomcat threads, 20 HikariCP DB connections), a brief 4-second Postgres lock contention exhausts all 200 Tomcat threads. Because /actuator/health shares Tomcat's pool and pings Postgres, all 24 pods fail liveness at 15 s, kubelet restarts the entire fleet, and 45-second JVM cold starts turn a 4-second hiccup into a 6-minute outage.

02
STAGE 02 · IMPACTL5 · APPLIED DESIGN

What happens when liveness probes share business pools or check Postgres.

Why this matters: The problem: see what breaks without What happens when liveness probes share business pools or check Postgres under real concurrency or scale.

Coupling livenessProbe to downstream dependencies or Tomcat's main worker pool triggers a self-inflicted death spiral:

  1. False-Positive Liveness Kills: Restarting a healthy JVM because Postgres paused for 4 seconds only destroys warm JIT caches and active connections.
  2. Cold-Start Kill Loop: Without startupProbe, 45-second Spring boot times exceed failureThreshold * periodSeconds, trapping pods in CrashLoopBackOff.
  3. CFS Throttling Starvation: Tight 1 s probe timeouts under limits.cpu: 2 get delayed by Linux CFS pauses.
Probe Coupling Failure vs. Isolation

4s Postgres Lock: Coupled Liveness Death Spiral vs. Isolated /readyz

KubeletMgmt Port :8081Tomcat :8080Postgres1. 4s lock -> 200 Tomcat threadsblocked2. GET :8081/livez -> 200 OK(<5ms)3. GET :8081/readyz -> 503NotReady4. Remove pod from Endpoints (nokill)5. Lock clears -> /readyz 200 OK

Isolating /livez on port 8081 with zero DB checks keeps pods alive while /readyz sheds traffic until Postgres recovers.

Engineering Decision Framework
Problem
How to implement Designing Safe Liveness & Readiness Probes without hitting unbounded tail latency, state divergence, or operational fragility.
Naive Solution
Use a single unpartitioned path with unbounded retries and synchronous global coordination.
Why It Fails
Global coordination serializes throughput under load, while unbounded retries amplify transient stalls into full outages.
Alternatives
Compare synchronous strict-consistency paths against bounded asynchronous replication, local caching, or partitioned ownership.
Engineering Decision
When /actuator/health is wired to both livenessProbe and readinessProbe (`timeoutSeconds, never put downstream DB/Redis checks in livenessProbe, isolate management endpoints on a separate thread pool/port, and use startupProbe for slow JVM cold starts.
Trade-Offs
Gains predictable p99 latency and fault isolation in exchange for explicit bounding, observability, and slightly higher implementation complexity.
Decision Exercise · Make the Call

When Designing Safe Liveness & Readiness Probes experiences a sudden 5x traffic spike alongside a slow downstream dependency, which engineering choice best protects system stability?

03
STAGE 03 · NAIVE SOLUTIONL5 · APPLIED DESIGN

Naive solution (and why raising liveness timeouts alone isn't enough).

Why this matters: The problem: see what breaks without Naive solution under real concurrency or scale.

Simply bumping timeoutSeconds from 1 s to 5 s on /actuator/health leaves the core flaw intact:

  • Shared Thread Pool: If all 200 Tomcat threads are blocked on Postgres, /actuator/health still sits in the Tomcat accept queue.
  • Wrong Signal Semantics: livenessProbe means 'this process is wedged and only a restart can fix it'—a slow downstream DB is never fixed by restarting the caller.
Lifecycle & Failure Recovery

Naive solution (and why raising liveness timeouts alone isn't enough)

admitsucceedbudget exceededInitializedProcessingInvariant MetDegraded Fallback
04
STAGE 04 · ENTERPRISE SOLUTIONL6 · SCALE & TRADE-OFFS

Enterprise solution: Dedicated Management Port + startupProbe + Shallow /livez.

Why this matters: Operational control: configure bounds, failure handling, and safe production defaults.

Production Kubernetes services enforce three probe rules:

  • Dedicated Management Port (8081): Run Spring Boot's management server on a separate port and tiny dedicated thread pool (management.server.port=8081) so saturated business threads on 8080 never block health checks.
  • Three-Probe Separation:
  • startupProbe (/livez, periodSeconds: 5, failureThreshold: 15): gives 75 s for 45s JVM + Spring boot.
  • livenessProbe (/livez, timeoutSeconds: 3): checks only in-process liveness (zero DB/Redis/downstream calls).
  • readinessProbe (/readyz, timeoutSeconds: 2): checks HikariCP pool health / circuit breakers to remove overloaded pods from EndpointSlice without restarting them.
Kubernetes Pod Probe Lifecycle

Startup (75s budget) -> Live & Ready <-> NotReady (DB Stall)

Spring context upDB pool saturatedDB recoversProcess deadlockSTARTINGstartupProbe (up to 75s)READY/livez=200 & /readyz=200NOT_READY/livez=200, /readyz=503RESTARTOnly if /livez fails

Downstream stalls transition pods to NOT_READY via /readyz without ever triggering a /livez container restart.

# Spring Boot application.yaml + Kubernetes PodSpec
# management.server.port: 8081
# management.endpoint.health.probes.enabled: true
# management.endpoint.health.group.liveness.include: livenessState
# management.endpoint.health.group.readiness.include: readinessState,db
startupProbe:
  httpGet: { path: /actuator/health/liveness, port: 8081 }
  periodSeconds: 5
  failureThreshold: 15   # 75s budget for 45s JVM cold start
livenessProbe:
  httpGet: { path: /actuator/health/liveness, port: 8081 }
  periodSeconds: 10
  timeoutSeconds: 3
  failureThreshold: 3
readinessProbe:
  httpGet: { path: /actuator/health/readiness, port: 8081 }
  periodSeconds: 5
  timeoutSeconds: 2
  failureThreshold: 2
05
STAGE 05 · SYSTEM DESIGN APPLICATIONSL7 · STAFF / PRINCIPAL

Where Safe Probe Design applies in Kubernetes Architectures.

Why this matters: Scope boundary: identify where this pattern fits best and where simpler or async alternatives win.

Proper startupProbe / livenessProbe / readinessProbe separation is mandatory for resilient K8s workloads:

  • JVM & Python ML Services: Preventing CrashLoopBackOff during 30–90 s model or Spring context loading.
  • Database-Backed Microservices: Shedding traffic via /readyz during Postgres failovers without losing warm connection pools.
  • High-Concurrency Gateways: Isolating health checks from business thread pools and CFS throttling.
Practice · Explain the consequences

Practice: Make the trade-off yourself.

Question 1 of 3
Score: 0/3

Why should livenessProbe never check downstream Postgres connectivity or share the main Tomcat request thread pool?

Recommended Learning Flow