A cold start is the work a platform does before your code runs: allocating an instance, pulling the image, initialising the runtime, then executing your initialisation code. It happens on the first request to an idle instance, and with autoscaling it happens on every burst. The usual conversation stops at how many milliseconds it adds. The more useful conversation is about what those milliseconds cost in three separate currencies: user-visible latency, billed duration, and the concurrency ceiling you must provision for because instances are still warming while the queue grows.
The short version: measure the cold start distribution, not the average, and separate init work from request work. Most of the recoverable cost sits in your own initialisation code, not in the platform’s allocator.
Three components, only one of them yours
Platform allocation is the time to find or create a sandbox; you influence it only by choosing a runtime, an image size, and a memory configuration. Runtime initialisation is loading the language runtime and its dependencies; a fat dependency tree is the most common reason a Node or Python function takes seconds to warm. Your own initialisation is whatever runs at module scope: database connection pools, configuration fetches, SDK clients, model loading.
Instrumentation that separates these three changes the whole conversation. Log a timestamp at process start, at the top of the handler, and after the first outbound call. The gap between the first two is the runtime-plus-your-init cost; the gap after that tells you whether lazy initialisation is spreading cost into the request. Without this split, teams often blame the platform for time that is entirely their dependency list.
Billed duration includes the warm-up
Most functions-as-a-service platforms bill wall-clock duration from invocation to return, and initialisation counts. A function with a two-second init and fifty milliseconds of real work bills roughly two seconds for its first invocation and fifty milliseconds afterwards. At low traffic, that init is a visible share of the bill; at high traffic, it is noise. This is why cost optimisation advice that works for a busy service can be actively wrong for a quiet one.
Two structural fixes dominate: reduce the dependency tree, and move expensive clients out of the handler into a lazily created, reused singleton where the runtime supports reuse. Both are done once and apply to every cold start afterwards. A third, provisioning a minimum concurrency, removes cold starts entirely at the price of paying for idle capacity, which is a legitimate trade for revenue-generating endpoints and a poor one for internal batch jobs.
Concurrency is the hidden constraint
When a burst arrives, the platform must create instances before it can serve requests. Creation rate, not steady-state throughput, becomes the limiting factor. A service that handles a hundred requests per second when warm may serve far fewer during the first ten seconds of a spike, because instances are initialising. Callers see timeouts, retry, and add load precisely when capacity is scarcest.
This is the classic cold-start amplification failure: retries during scale-up turn a slow start into an outage. Two mitigations are standard. First, do not retry aggressively in the caller during the first seconds of a spike; use exponential backoff with jitter and a total budget. Second, cap the concurrency at the queue rather than letting unbounded requests pile up behind a scaling function, so the overload is rejected quickly and visibly instead of timing out slowly.
Memory settings are a pricing dial
Many platforms price by memory-times-duration and allocate CPU proportionally to memory. Increasing memory can therefore lower total cost by making the function faster, up to the point where the extra memory dominates. The effect is measurable in an afternoon: run the same workload at two memory settings, record duration and billed cost, and pick the minimum of the cost curve rather than the minimum of duration. The two minima are frequently different.
Watch for the second-order effect on cold starts. More memory often means a larger image and a slightly longer initialisation, which interacts with the concurrency ceiling. The only way to see this is a load test that starts from zero instances, which is the test most teams never run.
What actually reduces cold starts
In descending order of typical impact: cut the dependency tree, prefer a runtime with a faster bootstrap, move heavy clients into reused global scope with lazy connection, keep the deployment package small, and avoid loading configuration from the network at init. Provisioned concurrency is the last resort, because it is the only one that costs money for idle time.
If cold starts remain visible after all of that, the question becomes whether the workload belongs on functions at all. A service with steady, non-spiky traffic and a latency budget under a hundred milliseconds is usually cheaper and more predictable on a small always-on container. Serverless is a scaling product, and it is priced accordingly.
A worked example of the same function, three ways
A Node function serves a product-price lookup. The initial version imports the whole AWS SDK, a logging library, and a date library at module scope, and builds a database pool inside the handler. Cold start measures 3.4 seconds, warm requests 45 milliseconds, and the memory setting is 512 MB. Two hundred invocations a day means most requests are cold, so the p95 latency a user sees is close to three seconds and the bill is dominated by initialisation.
The second version imports three specific SDK clients instead of the meta-package, drops the date library for native formatting, and creates the pool lazily at module scope with a five-second connection timeout. Cold start falls to 1.1 seconds and the package shrinks from 38 MB to 9 MB. The third version moves the lookup behind a small cache with a sixty-second TTL, so roughly eighty percent of invocations never reach the database at all. Cold start is unchanged but warm cost drops by two thirds, because the common path is now a cache hit rather than a pool checkout and a query.
None of these changes required a code rewrite. All three came from the same decomposition: init time, request time, and how many requests there are. That decomposition is what tells you whether to attack the dependency tree, the client construction, or the routing.
What to check before you commit
- Log init start, handler start, and first outbound call separately; do not average them.
- Measure cold start as a percentile (p95, p99), not a mean.
- Run the same workload at two memory settings and compare billed cost, not duration.
- Load test starting from zero instances; the scale-up rate is the real ceiling.
- Use bounded concurrency plus backoff with jitter so retries do not amplify the spike.
- Re-evaluate whether spiky, latency-critical work belongs on functions at all.
Cold starts are not a platform flaw to be endured. They are a property of a design that can be measured, priced, and mostly designed away, and the measurements are cheap enough to take before the first user complains.


