The symptom and two explanations#
A fictional pricing service ran six instances of build v17 with a p50 of about 40 ms. At 12:00 UTC a deploy replaced four of them with v18, and for the next five minutes the service's p50 sat between 70 and 90 ms. The engineer who shipped v18 says it is warm-up; the on-call engineer wants to roll back.
- Warm-up. Any freshly started instance is slow for a few minutes: its in-process caches are empty, its connection pool opens connections on first use, a JIT compiler has not yet compiled the hot paths, and lazily initialised clients connect on their first request.
- Regression.
v18does more work per request, or slower work, and will stay slower once warm.
Both explain the graph, and both can be true at once. The fleet p50 over the first minutes after the deploy mixes them, because every v18 instance is also a young instance. Rolling back does not settle it either, because a rollback starts fresh instances that warm up as well. Does a rollback prove the release caused it?
What each explanation predicts#
| Observation | Warm-up | Regression |
|---|---|---|
| Fleet p50 in the first minutes after the deploy | rises | rises |
v18 p50 at 0 to 2 minutes of uptime | high | high |
| Old-build instances restarted at the same time, 0 to 2 minutes | as high as v18 | lower than v18 |
v18 p50 after 10 minutes of uptime | back to the old build's | still above the old build's |
| Gap between builds at equal uptime | none | roughly constant |
The separating observation is the comparison at equal uptime, and the bucket after the instances are warm settles it. Without old-build instances of the same age there is nothing to compare a young v18 instance with, which is why the deploy's own graph cannot decide.
The lab: bucket by uptime#
The script simulates 60,000 requests over the 30 minutes after a deploy, across four new v18 instances and two v17 instances restarted at the same time. Every instance follows the same warm-up curve: five times slower at start, decaying with a time constant of 90 seconds. In the regression world, v18 is also 30% slower at every age. It needs Python 3.8 or later.
import math, random, statistics, sys
BUCKETS = [(0, 1), (1, 2), (2, 5), (5, 10), (10, 30)] # instance uptime, minutes
def requests(world, seed=4):
"""30 minutes after 12:00 UTC: four fresh v18 instances and two v17 instances restarted with them."""
rng = random.Random(seed)
instances = [("v18", rng.uniform(0, 60)) for _ in range(4)] + [("v17", rng.uniform(0, 60)) for _ in range(2)]
for _ in range(60_000):
build, started = rng.choice(instances)
t = rng.uniform(started, 1800) # seconds after 12:00
age = t - started
ms = rng.lognormvariate(math.log(40), 0.25) # warm v17: about 40 ms
ms *= 1 + 4 * math.exp(-age / 90) # caches, pools and JIT fill in minutes
if world == "regression" and build == "v18":
ms *= 1.3
yield build, age / 60, ms
if len(sys.argv) < 2 or sys.argv[1] not in ("warmup", "regression"):
sys.exit("usage: python3 warmup.py warmup|regression")
world = sys.argv[1]
rows = list(requests(world))
first5 = [ms for b, age, ms in rows if age < 5]
print(f"world={world} p50 of all requests, first 5 min of uptime: {statistics.median(first5):.0f} ms")
print(" uptime v17 restarted v18")
for lo, hi in BUCKETS:
cells = [statistics.median([ms for b, age, ms in rows if b == build and lo <= age < hi]) for build in ("v17", "v18")]
print(f" {lo:>2}-{hi:<2} min {cells[0]:6.0f} ms {cells[1]:4.0f} ms")
Save it as warmup.py. Before running it, write down which buckets will show a gap between the builds in each world. Then:
python3 warmup.py warmup; python3 warmup.py regression
Python 3.11 printed:
world=warmup p50 of all requests, first 5 min of uptime: 74 ms
uptime v17 restarted v18
0-1 min 155 ms 155 ms
1-2 min 100 ms 100 ms
2-5 min 57 ms 57 ms
5-10 min 41 ms 41 ms
10-30 min 40 ms 40 ms
world=regression p50 of all requests, first 5 min of uptime: 88 ms
uptime v17 restarted v18
0-1 min 155 ms 201 ms
1-2 min 100 ms 130 ms
2-5 min 57 ms 74 ms
5-10 min 41 ms 54 ms
10-30 min 40 ms 52 ms
Both worlds show a fleet p50 near double the old 40 ms in the first five minutes, the number the on-call engineer was reading. Bucketed by uptime, the warm-up world shows no gap between builds at any age, and the regression world shows v18 about 30% slower in every bucket, still 52 ms against 40 ms after ten minutes. The equal medians in the warm-up world are partly rounding; at one decimal they differ by under half a millisecond. The prediction fails if the warm-up world shows a gap that persists after ten minutes, or the regression world's gap closes. Change seed=4 to repeat it, or change the 1.3 to 1.1 to see how small a regression the 10-to-30-minute bucket can still show with this much traffic.
Read it on a real system#
The observation needs, for each instance, its build, its start time and its latency. Prometheus client libraries export process_start_time_seconds, the process start time in seconds since the Unix epoch, so uptime is time() minus it. Prometheus client library guidelines
time() - process_start_time_seconds{service="pricing"}
histogram_quantile(0.5,
sum by (le, instance, version) (rate(http_server_request_duration_seconds_bucket{service="pricing"}[1m])))
Read both at several moments and put each instance's latency beside its uptime. On a host, ps -o pid,etimes,args prints each process's elapsed time since it started, in seconds. ps(1) Request logs that carry an instance ID and the instance's start time can be grouped by uptime bucket directly, as the lab does.
If no old-build instance restarted during the deploy, make one: start one instance of the old build beside the new ones. This changes production state (it adds or replaces an instance), so do it as you would any deploy step. Its first minutes are the warm-up curve with no code change.
Then check what the warm-up consists of, since each part has its own evidence. Connection pool sizes and acquire waits show pools filling. Cache hit ratios by instance show caches filling. For a JVM, HotSpot compiles a method only after it has run enough times, and -XX:CompileThresholdScaling moves that threshold; a warm-up that tracks request count more than wall time points that way. The java command
A load balancer can hide warm-up from users. An AWS Application Load Balancer target group with slow start mode "linearly increases the number of requests that it can send to a target" for the configured duration after it becomes healthy, which "gives targets time to warm up". ALB slow start mode The same setting reduces how many requests a young instance serves, so per-instance latency buckets have fewer samples in their first minutes.
Limits#
A new build can lengthen warm-up without a steady-state regression, for example by adding a cache that takes longer to fill or a client that connects lazily. Then v18 is slower than a restarted v17 at two minutes and equal at ten. That is a real difference worth recording, and it is not the same finding as a regression.
Warm-up that depends on traffic, such as a cache filling from requests, converges faster on a busy instance than on a quiet one. Compare instances with similar request rates, or bucket by requests served since start instead of minutes.
Low traffic leaves the late buckets thin. The lab's 10-to-30-minute bucket held thousands of requests per build; a service with a few requests a minute per instance needs a longer window before the comparison means anything. If the database or another dependency also changed at the deploy, its effect lands on every instance regardless of age. For the method behind the table, see Choose the observation where explanations disagree; for comparing like requests across revisions, see Did a deploy cause the latency spike?
Questions#
How long should I wait before judging a new build's latency?
Until both builds have instances past the point where the warm-up curve flattens. Read that point from an old-build restart, not from a guess; in the lab it was about five minutes, and real services range from seconds to the time a large cache takes to fill.
Why is the old build not slow after a rollback, if warm-up is real?
It usually is, for the same few minutes. A rollback that looks instantly fast often moved traffic to old instances that were already running and warm. Check whether the rollback started new instances before using it as evidence.
Can I compare a new instance with an old one that has been up for days?
Only after the new one is warm. Before that the difference mixes warm-up with any regression, which is the comparison the uptime buckets exist to avoid.