Cold Start
ELI5 — The Vibe Check
A cold start is the delay you get when a serverless function hasn't been used for a while and the cloud needs to spin up a fresh container to run it. It's like a restaurant that closes between lunch and dinner — you're the first customer after the break and have to wait for them to reopen and prep the kitchen.
Real Talk
A cold start occurs when a serverless function receives a request but no warm container is available. The runtime must provision a new container, initialize the environment, load dependencies, and run initialization code before handling the request. Cold starts add hundreds of milliseconds to seconds of latency depending on the runtime and bundle size.
Show Me The Code
// Reduce cold starts: keep the handler lean,
// move heavy init outside the handler function
const db = initializeDatabaseConnection(); // runs once on cold start
export const handler = async (event) => {
// db is already warm on subsequent invocations
const result = await db.query('SELECT ...');
return result;
};
When You'll Hear This
"The cold start is adding 2 seconds to the first request after inactivity." / "Use provisioned concurrency to avoid cold starts for latency-sensitive functions."
Related Terms
Cloud Function
A cloud function is a piece of code you deploy to the cloud that runs when triggered — by an HTTP request, a file upload, a timer, or another event.
Edge Function
Edge functions run your code at the CDN edge — meaning close to the user, not in some faraway data center.
FaaS (Function as a Service)
FaaS is when you write a tiny function and deploy it to the cloud, and it only runs (and charges you) when someone calls it.
Lambda
AWS Lambda is where you upload a function and AWS runs it when something happens — an HTTP request, a file upload, a database change.
Serverless
Serverless doesn't mean there are no servers — it means YOU don't have to think about servers. Someone else manages them, scales them, and patches them.
Warm Start
A warm start is when your serverless function gets a request and a container is already running from a previous invocation — so it responds instantly witho...