code-anything.com
Sign inStart free

Guide

Serverless Cold Starts in 2026: Causes, Costs, and Cures for Production Apps

Serverless cold starts in 2026: causes, costs, and fixes. A plain-language guide to Lambda, Workers, provisioned concurrency, and monitoring for production apps.

Your checkout API takes three seconds to answer the first request after lunch, and the customer refreshes. That gap is a cold start.

A cold start is the delay your users feel the first time a serverless function runs after sitting idle. The platform must unpack your code, start a runtime, and load your handler before it can execute. In 2026, many platforms have pushed these delays into the sub-second range, but they still show up during traffic spikes, after deployments, and on infrequently used endpoints.

Key takeaways

  • A cold start happens when a provider spins up a fresh execution environment for an idle function.
  • You pay for idle readiness with provisioned concurrency, or you pay in latency if you do nothing.
  • Small deployment packages, fast runtimes, and initialization outside the handler are the cheapest fixes.
  • Cold starts cluster after deployments and traffic lulls; averages hide them, so measure them directly.

What is a serverless cold start, and why does it happen?

A cold start is the delay between a request arriving and your function beginning to run, caused by the provider creating a fresh execution environment. It happens because serverless platforms destroy idle environments to save resources, so the next request pays for setup: downloading code, starting the runtime, and initializing your handler. A warm start reuses an already-running environment.

In plain terms, "serverless" does not mean there are no servers. It means you do not manage them. The provider runs your code in an execution environment—a temporary container or isolate with its own runtime and memory. When that environment does not exist yet, the provider must build it. That build time is the cold start.

The timeline usually looks like this:

  1. Request arrives.
  2. Provider finds no warm environment for that function.
  3. Provider provisions a micro-VM or isolate.
  4. Runtime starts.
  5. Your handler code loads and runs initialization logic.
  6. The request finally executes.

Steps 3 through 5 are the cold start. Step 6 is the actual work your user waited for.

Modern platforms have gotten much faster at this. Shattered's 2026 latency tests found serverless cold starts sinking to sub-second times on several major platforms. That is real progress, but sub-second is still an eternity compared to a warm invocation that takes milliseconds. And sub-second in a test lab is not the same as sub-second under production load with a VPC attachment, a large deployment package, and a cold database connection.

AWS Lambda cold start fixes 2026

AWS Lambda reduces cold starts through Lambda SnapStart and Provisioned Concurrency. SnapStart restores a pre-initialized environment from a snapshot, so the runtime and handler do not start from scratch. Provisioned Concurrency keeps a fixed number of environments warmed and ready. Both shift initialization off the critical path, but neither applies to every runtime.

SnapStart takes a snapshot when you publish a function version. On invocation, Lambda restores that snapshot instead of booting from zero. It is available for supported runtimes only, and initialization logic still runs once per snapshot.

Provisioned Concurrency is a paid option. You choose how many environments to keep warm, and Lambda maintains them whether they receive requests or not. I treat it as an insurance policy for latency-sensitive endpoints, not a default setting. If your traffic is steady, on-demand Lambda is usually cheaper and fast enough.

Cloudflare Workers cold start

Cloudflare Workers run inside V8 isolates instead of virtual machines or containers. An isolate is a lightweight JavaScript sandbox that starts in milliseconds, so Workers usually avoid the multi-second cold starts common on container-based platforms. There is no operating system to boot.

The trade-off is scope. Workers are built for JavaScript and WebAssembly, and the environment is more constrained than a full function service. The first request after a deployment can still be slower because the isolate and script must initialize, but this is a cold script start, not a cold infrastructure start.

Some advanced routing, durability, and compute features sit behind paid plans. The baseline cold start behavior is part of the platform architecture, not a toggle you flip.

Reduce cold start latency serverless

The fastest way to reduce cold start latency is to make initialization smaller and faster.

  • Shrink your deployment package. Remove unused dependencies and assets. Every extra megabyte takes longer to download and unpack.
  • Choose a runtime with quick startup. Go, Rust, and Node.js generally initialize faster than Java or .NET, which carry heavier runtimes.
  • Move heavy setup outside the handler. Database clients, SDK objects, and large imports should run once when the environment starts, not on every request.
  • Avoid VPC attachments unless you need them. Attaching a function to a VPC can add network interface setup time to the cold start.

These are mechanical changes, not magic. They shave time off the init phase, and they cost nothing.

Optimizing serverless function initialization

Initialization is everything that runs before your handler code. Optimize it by deferring what you can, caching what you cannot defer, and avoiding work that blocks the event loop.

Create database clients and SDK objects in global scope, outside the handler, and reuse them across invocations. If you create a new database connection on every request, you pay connection setup time on warm starts too, not just cold starts.

Load large configuration files or models lazily. Pull them into memory only when the first request actually needs them, so a request that never touches that path does not pay for it.

For engineers, this means writing tests that measure initialization time in isolation, not just end-to-end latency. It means typechecking your global scope so a missing environment variable fails at deploy time, not at runtime. For founders, it means asking your team: what runs before the handler, and can it wait?

Provisioned concurrency vs cold starts

Provisioned concurrency keeps a set number of function environments pre-warmed so requests never wait for initialization. It trades a predictable hourly cost for near-zero cold start latency. On-demand concurrency costs nothing while idle but can pause between requests.

ApproachCost when idleFirst-request latencyBest for
On-demand$0Higher; cold start possibleSporadic, low-traffic endpoints
Provisioned concurrencyHourly fee per environmentNear-zeroUser-facing APIs with strict latency SLAs
Lambda SnapStartNo idle feeLow, on supported runtimesJava or Python functions with heavy initialization

The table makes the trade-off look simple, but it is not. Provisioned concurrency is behind a paid plan, and you must choose the right number of environments. Too few, and you still get cold starts during bursts. Too many, and you pay for idle capacity. SnapStart is narrower than the industry phrase "cold start fix" suggests: it only works on supported runtimes and does not eliminate all initialization.

My rule of thumb: measure first. If cold starts affect a small share of requests and never coincide with checkout or signup flows, do not pay to eliminate them.

Serverless cold start cost impact

Cold starts cost you in two ways: user-facing latency and, if you fight them with provisioned concurrency, idle infrastructure fees.

A pause on a checkout path can lose conversions. A slow login screen can make users think the site is broken. These are revenue costs, and they are hard to measure because they show up as drop-offs, not error codes.

The infrastructure cost is easier to see. If you keep environments warm around the clock, you pay for them even at 3 a.m. when no one is using the app. That cost is predictable, but it is still a cost.

The cost impact is highest for spiky, low-frequency traffic. A reporting endpoint used once a month does not need warm environments. A payment endpoint used by every customer does. Match the fix to the traffic pattern, not to the industry trend.

Serverless cold start monitoring

You cannot fix what you do not measure. Track cold start frequency, initialization duration, and total invocation duration separately. Most platforms tag cold starts in logs or traces, and you should alert when cold start latency exceeds your SLO or spikes after a deployment.

Watch for these patterns:

  • Cold starts clustering right after a deployment. This means your new code is heavier or your runtime changed.
  • Cold starts during traffic lulls. This means the provider scaled down environments too aggressively.
  • Cold starts on specific endpoints only. This means those functions have larger packages or heavier initialization.

Use distributed tracing where you can. A cold start in one function can cascade into a slow response in an API gateway or frontend. Logs that only show total duration will blame the handler when the real culprit was initialization.

GPU and model cold starts (advanced)

For serverless GPU inference, cold starts are dominated by model weight loading and CUDA context setup, not just code startup. A web API might cold start in a few hundred milliseconds; an LLM inference function can take tens of seconds to load model weights onto a GPU.

Spheron's October 2026 guide lists four fixes that actually work for this class of problem: streaming model weights instead of downloading the whole file, using CUDA graphs to pre-record kernels, and keeping a small pool of GPU containers warm. These are advanced techniques for LLM workloads, not standard web APIs.

If you are running serverless AI inference, your cold start strategy starts with the model, not the function code.

What I would actually do in production

I would not buy provisioned concurrency by default. I would start with on-demand, measure cold starts under real traffic, and only pay for warm environments if the data shows latency hurting conversion or SLOs.

I would keep deployment packages small, initialize clients outside the handler, and monitor initialization duration as a first-class metric. If I were running GPU inference, I would look at model weight streaming before I looked at keeping GPU instances warm around the clock.

The honest answer is that most production apps do not need elaborate cold start engineering. They need small packages, a fast runtime, and visibility into what happens before the handler runs. Everything else is an optimization you buy only when the metrics justify it.

If you are running serverless in production and want help auditing initialization time, we review cold start traces and initialization paths as part of our platform work at code-anything.com.

FAQ

How long does a serverless cold start last in 2026?

It depends on the platform and runtime. Shattered's 2026 latency tests found sub-second cold starts on several platforms, but production cold starts often run longer with VPCs, large packages, or heavy runtimes.

Does provisioned concurrency eliminate cold starts completely?

No. It keeps environments warm so most requests avoid initialization, but scaling beyond your provisioned capacity or deploying a new version can still trigger cold starts.

Which language has the fastest cold starts?

Generally, Go, Rust, and Node.js initialize faster than Java or .NET because their runtimes are lighter. The exact difference depends on your code and dependencies.

Do I need to worry about cold starts if my API gets steady traffic?

Probably not. Steady traffic keeps environments warm. Cold starts matter most for infrequently used endpoints, post-deployment traffic, and sudden spikes.

How do I tell if a slow request was a cold start?

Look for an initialization or init duration field in your platform logs or traces. If the total duration is high but the handler duration is low, the time was spent setting up the environment.

All guides

Stop reading. Start shipping.

Describe what you want and watch it build — or connect a repo and ship a reviewed PR.