Scrivio Interview library
DebuggingFoundations7 min read · updated 13 November 2026

A Spring Boot API runs 8 pods on Kubernetes at 60 percent CPU at midday. Its Deployment uses RollingUpdate with maxUnavailable: 25% and maxSurge: 0. New pods need about 90 seconds after the readiness probe passes before their latency is normal, because of JIT warm-up and empty caches.

During every midday deployment p99 latency jumps from 150 ms to 3 seconds for several minutes. Explain why, and which settings and practices fix it.

The rollout removes capacity and adds slow capacity at the same time. With maxUnavailable 25 percent and maxSurge 0, Kubernetes stops 2 of the 8 pods before adding replacements, so 6 pods carry the load of 8 at about 80 percent CPU, and the new pods pass readiness while still cold and receive a full share of traffic they serve slowly. The fix is maxSurge 25 percent with maxUnavailable 0, a warm-up before readiness, slow start or minReadySeconds, and a rollout that is watched and paused automatically.

Why this question is asked

Latency spikes during deployments are one of the most common complaints in Kubernetes teams, and they are usually blamed on the new code. Interviewers like this question because the real cause is arithmetic: how many pods are serving, and how fast each of them can serve. In this answer, we will recap how a RollingUpdate works, do the capacity calculation for this service, see why cold JVMs make it worse, and then go through the settings and practices that fix it.

1A Quick Recap of RollingUpdate

A Kubernetes Deployment replaces old pods with new ones gradually. Two settings control the pace. maxUnavailable says how many pods below the desired count we may drop during the rollout. maxSurge says how many extra pods above the desired count we may add. Both can be numbers or percentages of the replica count.

A readiness probe is the check Kubernetes uses to decide whether a pod may receive traffic. When it passes, the pod is added to the Service endpoints and the load balancer starts sending it requests. In Spring Boot the probe usually calls /actuator/health/readiness, which reports UP once the application context has started.

2Doing the Capacity Arithmetic

We have 8 pods at 60 percent CPU. With maxUnavailable 25 percent, Kubernetes may drop 2 pods, and with maxSurge 0 it may not add any first. So it terminates 2 old pods and starts 2 new ones in their place. For the time it takes the new pods to start, 6 pods carry the load of 8.

The load per pod rises by 8 / 6, so 60 percent becomes about 80 percent CPU. At 80 percent a Java service usually still works, but queues start to form in thread pools and connection pools, and tail latency, the p99, grows much faster than the average. And this is before we count the effect of the new pods themselves.

Serving capacity during the rollout
SettingPods serving wellCPU per old pod
Before the deployment860 percent
maxUnavailable 25%, maxSurge 06 old + 2 coldabout 80 percent, plus slow new pods
maxSurge 25%, maxUnavailable 08 old + 2 warming60 percent or less

3Why Cold Pods Make It Worse

A freshly started JVM is slow for a while. The JIT compiler, the part of the JVM that turns hot bytecode into optimised machine code, has not yet compiled the hot paths, so the code runs interpreted or at a low optimisation level. Caches are empty, so every request goes to the database or downstream services. Connection pools may still be opening connections. In this service, it takes about 90 seconds after readiness passes before latency is normal.

But readiness passes as soon as the context starts, so the load balancer gives each new pod a full one-eighth share of traffic immediately. Those requests are served slowly, they hold threads and connections longer, and some time out and are retried, adding more load to the 6 old pods. Meanwhile the next batch of 2 old pods is already being stopped. So for several minutes the service runs with too few healthy pods, and p99 goes from 150 ms to 3 seconds.

4Fix 1: Surge First, Never Drop Capacity

The first fix is to add before we remove. With maxSurge 25 percent and maxUnavailable 0, Kubernetes starts 2 extra pods, waits until they are ready, and only then terminates 2 old pods. The number of pods serving never falls below 8.

YAML
apiVersion: apps/v1
kind: Deployment
spec:
replicas: 8
minReadySeconds: 60 # a new pod must stay ready 60 s before it counts as available
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 25% # 2 extra pods during the rollout
maxUnavailable: 0 # never fewer than 8 available pods

The cost is that the cluster needs room for 2 extra pods during the deployment, which is usually cheap. minReadySeconds slows the rollout: Kubernetes waits until a new pod has been ready for 60 seconds before it treats it as available and moves on, which gives the JIT and caches time and stops a pod that crashes soon after start from being counted as healthy. Notice that minReadySeconds does not keep traffic away from the pod; the pod receives traffic as soon as it is ready. That is why we also need the next fix.

5Fix 2: Warm Up Before Saying Ready, and Ramp Traffic

We can make the application warm itself before it reports ready. Spring Boot keeps readiness at REFUSING_TRAFFIC until the application is started; we can run a warm-up when the ApplicationReadyEvent fires but keep refusing traffic until it finishes, calling the main endpoints or service methods a few hundred times and loading the hot cache entries.

Java
@Component
class WarmUp {
private final ApplicationEventPublisher events;
private final ProductService products;
WarmUp(ApplicationEventPublisher events, ProductService products) { this.events = events; this.products = products; }
@EventListener(ApplicationReadyEvent.class)
void warm(ApplicationReadyEvent e) {
AvailabilityChangeEvent.publish(events, this, ReadinessState.REFUSING_TRAFFIC);
for (int i = 0; i < 500; i++) products.find(42L + (i % 50)); // JIT and caches get exercised
AvailabilityChangeEvent.publish(events, this, ReadinessState.ACCEPTING_TRAFFIC); // probe now says UP
}
}

Where the load balancer supports it, slow start helps too. A slow-start window, such as the one in AWS Application Load Balancer target groups or in some service meshes, gives a new target a small share of traffic at first and raises it over a configured period, for example 90 seconds. Between warm-up, slow start and minReadySeconds, a new pod is never asked to do a full share of work while it is still cold.

6Fix 3: Deploy at the Right Time and Watch the Rollout

Even a well-configured rollout is safer when there is headroom. Deploying at midday at 60 percent CPU leaves little margin, so where possible we deploy at lower traffic, or scale up a little before deploying. And the rollout should be watched by the same latency and error alerts we use in normal operation, wired so that a firing alert pauses the rollout automatically. Tools such as Argo Rollouts or Flagger can analyse metrics between steps and pause or roll back on their own.

7Follow-up questions

Does a PodDisruptionBudget limit how many pods a rolling update stops?

No. A PodDisruptionBudget limits voluntary disruptions that go through the eviction API, such as draining a node for maintenance or a cluster autoscaler removing a node. A Deployment rolling update deletes pods through its ReplicaSets and is controlled by maxUnavailable and maxSurge, not by the budget. So we need both: a budget to protect against node drains and correct rollout settings to protect against deployments.

Why not just set a long initialDelaySeconds on the readiness probe?

It delays readiness by a fixed time, but nothing happens during that time to make the pod warm, because the pod receives no traffic. The JIT only optimises code that runs. An explicit warm-up that exercises the hot paths before readiness reports UP actually warms the JVM, and it finishes as soon as warm-up is done rather than after a guessed delay.

Would a horizontal pod autoscaler fix this?

Not by itself. The autoscaler reacts to CPU averaged over a window and needs minutes to add and warm pods, which is longer than the spike. It also sees the cold pods as part of the fleet. Fixing the rollout settings removes the capacity drop in the first place, which is much cheaper than adding capacity to cover it.

8Conclusion

In this answer, we saw that the midday latency spike is caused by the rollout itself. maxUnavailable 25 percent with no surge removes 2 of 8 pods at once, pushing the rest to about 80 percent CPU, and readiness passes before the JVM is warm, so cold pods take a full share of traffic. Setting maxSurge 25 percent and maxUnavailable 0 keeps capacity, a warm-up before readiness plus slow start and minReadySeconds keeps cold pods from being overloaded, and deploying at lower traffic with alerts that pause the rollout catches whatever is left.

What to say in the interviewAbout 70 seconds aloud

Open with

The new code is probably not the problem; the rollout is. With maxUnavailable 25 percent and maxSurge 0, Kubernetes stops 2 of the 8 pods before starting replacements, so 6 pods carry the load of 8, which takes CPU from 60 to about 80 percent and makes tail latency climb.

Then, if they want more

On top of that, readiness passes as soon as Spring starts, but the JVM needs about 90 seconds to warm its JIT and caches, so the new pods immediately get a full share of traffic and serve it slowly, while the next old pods are already stopping.

To fix it I would set maxSurge to 25 percent and maxUnavailable to 0, so new pods are added before old ones go and capacity never drops.

Then I would make readiness honest: run a warm-up that calls the hot paths and loads caches before readiness reports UP, use slow start on the load balancer if it supports it, and add minReadySeconds so the rollout waits.

Finally I would deploy at lower traffic where possible and have the latency alerts pause the rollout automatically, for example with Argo Rollouts.

About this answer

Last updated
13 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 "During every midday deployment p99 latency jumps from 150 ms to 3 seconds for several...": https://scrivio-interview-library.netlify.app/architecture/high-availability/14aa3f7f5e/