Cold start
Also called: cold start latency, warm start, provisioned concurrency (the fix).
The extra wait when a serverless platform has no ready copy of your function and must start a new one first: set up the environment, load the language runtime and run your start-up code. That takes a few hundred ms for a small Node.js or Python function, and can pass 1 s for a Java function with heavy start-up code. A warm copy skips all of it, until the platform removes it after some idle time and the next request is cold again.
A Java function with heavy start-up code, so a cold start costs 1.8 s (a small Node.js or Python function starts in a few hundred ms). The bar shows one request's time, 1.9 s across. How long a platform keeps an idle instance is not promised; this demo uses 15 minutes.
Last request: none yet
Requests: 0 · Cold starts: 0 · Last: none
No instance is running yet. The first request will have to wait for one to start.
Say it in a prompt
Cut cold starts on the /report Lambda (Java): move SDK clients and config loading out of the handler, drop unused libraries to shrink the package, and set provisioned concurrency to 2 on the live alias during working hours (8:00 to 20:00). Log Init Duration so we can see how often cold starts happen. Vague vs precise prompt
Vague prompt
the Lambda is slow sometimes, fix it Typical resultDoubles the memory and adds a scheduled ping every 5 minutes. The ping keeps only one copy warm, so a burst of users still waits for new copies, and the cost goes up.
Precise prompt
Cut cold starts on /report: SDK clients and config out of the handler, drop unused libraries, provisioned concurrency 2 on the live alias 8:00 to 20:00, log Init Duration. Typical resultStart-up work runs once per copy, two copies are always ready in working hours, and the Init Duration log shows how many requests still get a cold start.
Seen on
- AWS Lambda docs: Explains cold starts: Lambda downloads your code, starts the environment and runs init code before the handler; a reused environment is a warm start. Cold starts take from under 100 ms to over 1 second.
- AWS Lambda docs: Provisioned concurrency keeps a set number of environments initialized in advance, so requests to them have no cold start; it costs extra.
You might describe it as
- the first request after a quiet time is slow
- the Lambda takes seconds to wake up
- keep one copy warm so nobody waits
Not to be confused with
- Serverless function
A cold start is the delay when the platform must start a new copy of your function; serverless is the model where the platform starts and stops those copies for you.