Cold Start Percentiles
A serverless function runs inside an execution environment that the platform creates when needed and discards after a period of idleness. The first request to a new environment waits while the runtime boots, code loads, and initialisation runs. That wait is a cold start. Later requests to the same environment skip it and are called warm.
On AWS Lambda the delay appears in each invocation’s REPORT log line as Init Duration. Typical values run from 150 to 500 ms for small Node.js or Python functions and from one to several seconds for Java or .NET without snapshotting.
A percentile describes position in a sorted list of response times: p95 is the value 95% of requests beat. The trouble is that serverless latency has two populations. If 2% of requests are cold at 900 ms and the rest are warm at 80 ms, p95 reports about 80 ms and looks healthy, while p99 lands inside the cold group and jumps to roughly 900 ms.
One blended percentile cannot describe both groups.
Why Test Results Mislead
A standard load test ramps traffic gently and runs for several minutes. The platform creates a handful of environments in the first seconds, and nearly every request after that is warm. The report shows excellent latency and says almost nothing about first-request behaviour.
The opposite error comes from testing a function that has been idle for an hour with ten sequential requests. One in ten is cold, so the cold share is 10%, far above anything production would see under steady load. AWS has said cold starts typically affect under 1% of invocations in production workloads, though bursty or low-traffic functions sit well above that.
Closed-loop load generators add a quieter distortion. A tool with 20 virtual users that each wait for a reply never has more than 20 requests in flight, so it never forces the platform past 20 environments. Real traffic arrives regardless of how slow the last answer was, which, frankly, is the whole reason cold starts cluster during spikes.
Results also depend on platform mechanics. Concurrency needed equals arrival rate multiplied by average duration: 50 requests per second at 200 ms each needs about 10 environments. A jump to 200 per second needs 40, so 30 are created cold at once. Lambda scales each function by up to 1,000 concurrent executions every 10 seconds. Idle environments are reclaimed after an undocumented interval, often several minutes. Memory setting changes CPU share, and package size changes load time.
Designing The Load Test
Tag Every Request Cold Or Warm
Record cold status per request instead of inferring it from latency. On Lambda, set a module-level flag that is true only on the first invocation and return it in a response header, or query CloudWatch Logs Insights for records where the init duration field is present. On Cloud Run and Azure Functions, the same in-code flag works. Then compute percentiles separately for the two groups and report the cold share as its own number.
Force Enough Cold Starts
A p99 of cold starts needs at least 1,000 cold samples, since the top 1% is then ten data points. Steady traffic will never produce that many. Two methods work. Publish a trivial configuration change, such as an environment variable with a timestamp, which invalidates all existing environments, then send a burst. Or step concurrency upward in stages: 10, then 50, then 200 simultaneous requests, each stage forcing new environments. Repeat the cycle 20 to 50 times. You change the variable, fire the burst, and the log fills with init records.
Use Open-Model Traffic Shapes
Drive load at a fixed arrival rate with k6’s constant-arrival-rate or ramping-arrival-rate executors, or Artillery’s arrival phases. Test three shapes: steady state at expected peak, a step from baseline to four times baseline within one second, and a return from idle after 30 to 60 minutes of silence. The step and idle-return shapes are where cold percentiles matter. Run the generator from the same region to keep network variance out of the reading.
Report Three Numbers
State warm p95, cold p95 or p99 with sample count, and cold share under each traffic shape. A line such as “warm p95 85 ms, cold p99 1,150 ms from 1,400 samples, cold share 0.6% steady and 7% during a fourfold step” lets a reader estimate user impact. A single p99 of 410 ms does not. Break init duration from handler duration as well, since only the first responds to packaging and snapshot fixes.
Two Test Scenarios
A Node.js API. A team tests an order-lookup function with 512 MB of memory. The original five-minute ramp test showed p99 of 140 ms. After tagging and forcing 1,400 cold starts across 40 cycles, they find cold init at a median of 380 ms and p99 of 1,150 ms. Most of the tail traces to loading a large SDK bundle at module level. They import only the two client modules they use and move a rarely needed PDF library behind a lazy load. Cold median drops to about 240 ms. The cold share during steps is unchanged, because that depends on scaling, not packaging.
A Java payment function. A Spring-based function shows cold starts of roughly 4.2 seconds at the median, which breaches the caller’s 3-second timeout. The team measures two remedies. Lambda SnapStart, which restores from a snapshot taken after initialisation, brings the median to around 600 ms with occasional restores above one second. Provisioned concurrency of 20 removes cold starts until traffic exceeds 20 concurrent requests, then they return at full length. Cost differs: the always-on capacity is billed around the clock. They choose SnapStart and add a retry with a short backoff in the caller. Not elegant. Adequate.
Mitigations Compared
| Approach | Effect On Cold Starts | Cost | Limits |
|---|---|---|---|
| Smaller package, lazy loading | Shortens each one, often by 30% to 50% | Engineering time only | Does not reduce how often they occur |
| Higher memory setting | Faster init through more CPU share | Higher per-millisecond rate, sometimes offset by shorter runs | Gains flatten beyond a point that testing must find |
| Snapshot restore | Replaces init with a restore, large gains for Java and .NET | Low; some runtimes carry snapshot charges | Runtime support varies; stale connections and random seeds need handling |
| Pre-warmed capacity | Removes them up to the configured level | Billed continuously, used or not | Traffic above the level still starts cold |
| Scheduled pings | Keeps one environment alive | Negligible | No help when concurrency exceeds one |
Pre-warmed capacity goes by different names: provisioned concurrency on Lambda, minimum instances on Cloud Run, always-ready instances on Azure Functions Flex Consumption.
Common Mistakes
Quoting a blended p99 as the cold start figure. Its value swings with the cold share in that run, so two tests of identical code can differ by a factor of five.
Measuring from one log sample. Init duration varies with host placement and image caching. Ten samples can miss the slow tail entirely.
Ignoring downstream warm-up. A new environment also opens database connections and fetches secrets. Those costs sit in the first handler call, not in the platform’s init figure, and it rarely shows up unless handler time is split out for cold requests.
Testing in a different configuration from production. Memory size, architecture (x86 or Arm), VPC attachment, and layers all change init time.
Forgetting cost during tests. Since August 2025, Lambda bills the init phase for standard functions, and forced cold-start cycles against pre-warmed capacity can run up charges. Set a budget alarm before a long campaign.
FAQ
What is a normal cold start time?
Roughly 150 to 500 ms for lightweight Node.js and Python functions, and one to several seconds for JVM or .NET functions without snapshots. Measure your own, since dependencies dominate.
Which percentile should I use for cold starts?
Report p95 or p99 of the cold group alone, with its sample count, next to warm p95 and the cold share. Avoid a single blended percentile.
How do I force a cold start for testing?
Change a function setting such as an environment variable or publish a new version, then send requests. Stepping concurrency above the number of warm environments also creates new ones.
Does provisioned concurrency remove cold starts completely?
Only up to the configured number of environments. Requests beyond that level spill to on-demand capacity and start cold.
How often do cold starts happen in production?
Often under 1% of requests for steady traffic. Spiky, scheduled, or rarely called functions see far higher shares, which is why the traffic shape tested matters.
Author’s Insight
Across platform documentation and published benchmarks, the recurring flaw in cold start reporting is a single number with no denominator. Duration and frequency are separate properties with separate causes: packaging and runtime choice drive the first, traffic shape and scaling behaviour drive the second. Remedies map onto one or the other, so a test that cannot tell them apart cannot say which fix is worth paying for. Published benchmark figures age quickly as runtimes change, and a team’s own tagged measurements are the only ones that reflect its dependencies. The method outlasts the numbers.
What to Remember
- Serverless latency has two populations, warm and cold, and a blended percentile misrepresents both.
- Tag each request as cold or warm in code or logs, then compute percentiles per group.
- Force at least 1,000 cold starts through configuration changes or concurrency steps before quoting a cold p99.
- Use fixed arrival rates and test steady, step, and idle-return traffic shapes.
- Report warm p95, cold p95 or p99 with sample size, and cold share for each shape.
- Packaging and snapshots shorten cold starts, pre-warmed capacity reduces their frequency, and each has a cost to measure. Platform limits and billing rules change, so confirm them in current documentation.