Serverless Load Testing: Cold Start Percentiles

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

ApproachEffect On Cold StartsCostLimits
Smaller package, lazy loadingShortens each one, often by 30% to 50%Engineering time onlyDoes not reduce how often they occur
Higher memory settingFaster init through more CPU shareHigher per-millisecond rate, sometimes offset by shorter runsGains flatten beyond a point that testing must find
Snapshot restoreReplaces init with a restore, large gains for Java and .NETLow; some runtimes carry snapshot chargesRuntime support varies; stale connections and random seeds need handling
Pre-warmed capacityRemoves them up to the configured levelBilled continuously, used or notTraffic above the level still starts cold
Scheduled pingsKeeps one environment aliveNegligibleNo 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.

Related Articles

Serverless Load Testing: Cold Start Percentiles

Functions that run on demand sometimes pause for a moment before answering, because the platform must first create a fresh execution environment. Ordinary load tests blur those slow first responses into the general numbers or miss them altogether. This guide is for developers, platform engineers, and technical leads who run workloads on AWS Lambda, Google Cloud Run, or Azure Functions and need latency figures they can defend. It explains how to separate first-request delays from steady traffic, how to provoke enough of them to measure, which percentile to report and with how many samples, and how the common remedies compare on effect and cost.

development

dailytapestry_com.pages.index.article.read_more

Performance Budgets in CI: p95 Thresholds That Hold

A performance budget is a speed limit written into the build pipeline: if a code change makes the slowest ordinary requests slower than an agreed figure, the merge is blocked. Teams adopt these gates and then switch them off within weeks because they fail at random. This guide is for backend and frontend engineers, tech leads, and anyone who maintains a delivery pipeline and wants latency checks that people trust. It explains what the 95th percentile measures, why shared build machines distort it, how many samples a stable reading needs, how to derive a limit from measured noise, and which gate designs suit which kind of test.

development

dailytapestry_com.pages.index.article.read_more

Software Supply Chains: SBOM Requirements in 2026

SBOMs (software bill of materials) list what software components a product uses, down to versions and licenses. This matters for healthcare-adjacent software, regulated vendors, and anyone buying or building connected systems. This article explains what SBOMs cover, what 2026 SBOM requirements typically target, and how to judge an SBOM’s quality. You’ll learn practical steps for procurement and engineering teams, common failure modes, and how to read an SBOM without getting misled.

development

dailytapestry_com.pages.index.article.read_more

Database Indexing: Finding the 99th-Percentile Bottleneck

Database indexing affects query latency, CPU use, and tail performance. This article explains how to locate the 99th-percentile bottleneck using query plans, index design, and workload measurements. It helps readers who manage apps, analytics, or data platforms understand why “fast average” can hide slow outliers. You’ll learn practical steps to diagnose index-related tail latency, compare options, avoid common mistakes, and interpret results safely.

development

dailytapestry_com.pages.index.article.read_more

Latest Articles

Software Supply Chains: SBOM Requirements in 2026

SBOMs (software bill of materials) list what software components a product uses, down to versions and licenses. This matters for healthcare-adjacent software, regulated vendors, and anyone buying or building connected systems. This article explains what SBOMs cover, what 2026 SBOM requirements typically target, and how to judge an SBOM’s quality. You’ll learn practical steps for procurement and engineering teams, common failure modes, and how to read an SBOM without getting misled.

development

Read »

Performance Monitoring Tools for Modern Applications

Modern application performance monitoring (APM) has evolved from simple server pings to complex observability across distributed microservices and hybrid cloud environments. This guide provides CTOs and DevOps engineers with a deep dive into selecting and implementing monitoring stacks that reduce Mean Time to Resolution (MTMR) and prevent revenue-leaking downtime. We address the transition from reactive alerting to proactive telemetry, ensuring your infrastructure supports high-scale traffic without degrading user experience.

development

Read »

AI-Generated Code and the EU Product Liability Directive

Europe’s rewritten product liability law treats software as a product and holds its maker answerable for harm without any need to show carelessness. It applies to anything released after 9 December 2026, and it draws no line between functions typed by an engineer and functions produced by a coding assistant. This guide is for founders, engineering leads, and product managers shipping apps, firmware, or connected devices to European users, and for consumers curious about their rights. It explains who counts as the manufacturer, which harms qualify, how courts can presume a defect, what records help a defence, and where vendor contracts stop protecting you

development

Read »

Prompt Injection in CI/CD: OWASP LLM Top 10 Controls

Prompt injection in CI/CD is a supply-chain risk where malicious text in code, dependencies, or build logs steers an LLM to leak secrets or change pipeline behavior. This guide targets engineers and security reviewers who use LLMs for code review, test generation, or release notes. You will learn how prompt injection reaches CI/CD, how OWASP LLM Top 10 controls map to pipeline controls, and what to measure in practice to reduce exposure.

development

Read »

Cybersecurity Basics for Developers

Modern software development moves at a breakneck pace, but speed often compromises the integrity of the codebase. This guide provides developers with a high-level technical roadmap for integrating security into the CI/CD pipeline, moving beyond basic "don't leak keys" advice to architectural resilience. By implementing specific shifts in authentication, input handling, and dependency management, engineers can mitigate 80% of common vulnerabilities before a single line of code reaches production.

development

Read »

Database Indexing: Finding the 99th-Percentile Bottleneck

Database indexing affects query latency, CPU use, and tail performance. This article explains how to locate the 99th-percentile bottleneck using query plans, index design, and workload measurements. It helps readers who manage apps, analytics, or data platforms understand why “fast average” can hide slow outliers. You’ll learn practical steps to diagnose index-related tail latency, compare options, avoid common mistakes, and interpret results safely.

development

Read »