Kubernetes liveness probe kills Spring Boot JVM pod during G1 GC pauses — pods restart under moderate load
Environment
Kubernetes 1.24 on managed cluster, Spring Boot 2.7 (OpenJDK 11) microservice, container resources requests 500m/512Mi and limits 1 CPU/1Gi, liveness probe HTTP /actuator/health with timeoutSeconds:1, periodSeconds:10, failureThreshold:3.
Symptoms
Pods restarted during normal traffic bursts. Application logs show occasional 1.2–2.5s stop-the-world G1 GC pauses and thread-dump timestamps correlate to liveness probe failures. After restart readiness passes but pod is later killed again.
Observations
Heap is ~70% at bursts and CPU throttling events in kubelet metrics correlate with GC duration spikes. Increasing liveness timeout to 2s reduced restarts but did not eliminate them. Readiness probe was not used to gate traffic before GC events. No deadlock traces present.
Already attempted
Raised liveness timeout to 2s, temporarily set failureThreshold to 5, increased CPU request to 700m for one deployment (pod restarts less frequent), added -XX:MaxGCPauseMillis=200 and -XX:+UseG1GC (already default).
Question
Best practice probe and JVM tuning to avoid false liveness kills during GC? How to tune without overprovisioning resources?
Verified community troubleshooting
No answers yet..
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags