JVM Warm-up issue for container gateways
search cancel

JVM Warm-up issue for container gateways

book

Article ID: 419712

calendar_today

Updated On:

Products

CA API Gateway

Issue/Introduction

we have noticed too high response time in the very first minute after a newly created Gateway pod starts handling the traffic.

Later on, the Gateway responds usually with less latency.

Environment

11.1

Resolution

A few recommendations are made based on VM's JVM suggestions and the nature of the observed delay (around 8 seconds).

1) JVM Flags to Reduce GC Pauses and Improve Startup Predictability

The following JVM options can help reduce allocation pauses during startup and make memory handling more predictable in containerized environments:

 

-XX:+UseG1GC

-XX:NewRatio=1

-XX:SurvivorRatio=6

-XX:+AlwaysPreTouch

-XX:+ParallelRefProcEnabled

-XX:+ExplicitGCInvokesConcurrent

-XX:+TieredCompilation

-XX:+AlwaysCompileLoopMethods

-XX:+UseContainerSupport

-XX:MaxRAMPercentage=75.0

-XX:InitialRAMPercentage=75.0

  • AlwaysPreTouch ensures memory is committed up front to avoid paging delays.
  • NewRatio and SurvivorRatio enlarge the young generation and survivor space, helping with the burst of allocations when the pod first handles traffic.
  • ParallelRefProcEnabled and ExplicitGCInvokesConcurrent reduce stop-the-world collection risks.
  • TieredCompilation and AlwaysCompileLoopMethods speed up JIT compilation of frequently used methods.
  • The container-related flags ensure the JVM respects resource limits and avoids resizing overhead.

These flags should reduce GC-related interruptions during startup, though the ~8 second latency is more likely related to JVM JIT warm-up and classloading.

 

2) Kubernetes Readiness Probe Configuration

To ensure traffic is only routed to the pod once Tomcat and the JVM are fully warmed up, we recommend using an application-level readiness probe instead of the current command-based script. Example:

 

readinessProbe:
 httpGet:
   path: /ssg/ping        # Replace with your service’s health/status endpoint
   port: 8443
   scheme: HTTPS
 initialDelaySeconds: 30  # Allow JVM/Tomcat to finish initialization
 periodSeconds: 10        # Probe interval
 timeoutSeconds: 5        # Allow a few seconds for the service to respond
 successThreshold: 1
 failureThreshold: 3

  • Ensures the pod is marked Ready only when the application is responsive, not just when the process is alive.
  • Delays routing traffic until the pod has completed JVM/Tomcat warm-up, avoiding cold-start latency for end users.