Skip to content

Cold Start

Medium — good to knowCloud & Infra

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."

Made with passive-aggressive love by manoga.digital. Powered by Claude.