Cold Start
The initial latency overhead incurred when a serverless function or scale-to-zero container boots a fresh execution sandbox, loads code, and initializes runtime dependencies on a first request
Table of Contents
Structure Diagram
What is Cold Start?
The initial latency overhead incurred when a serverless function or scale-to-zero container boots a fresh execution sandbox, loads code, and initializes runtime dependencies on a first request. It is a core concept in Containers & Orchestration within Cloud / DevOps.
Core Principles
A Cold Start happens in serverless or scale-to-zero platforms when no warm execution sandbox is available to handle an incoming request. Before running your handler, the platform must allocate a microVM/container, download your artifact, boot the language runtime, and execute top-level initialization code.
Even if median latency (p50) is 50ms, cold starts can push tail latency (p99) to 1–3 seconds during traffic bursts or after idle gaps—directly impacting user-facing APIs.
Practical Takeaways
- Shrink bundles and pick fast-booting runtimes: Tree-shaken TypeScript/Node.js, Go, and Rust start in tens of milliseconds, whereas heavy JVM or large Python dependency bundles take seconds. Lazy-load rarely used modules.
- Use Provisioned Concurrency or Min Instances: For latency-critical endpoints (checkout, auth), keep a small baseline of pre-warmed instances active to eliminate cold starts on live traffic.
- Hoist reusable clients outside the handler: Initialize SDK clients and connection pools at module scope so subsequent warm invocations reuse them cleanly.
Notable Examples
- AWS Lambda SnapStart: Pre-snapshots initialized JVM/Python/.NET memory state to slash cold start latency by up to 90%.
- Cloudflare Workers (V8 Isolates): Uses lightweight V8 isolates instead of full containers for near-zero cold starts.
- AWS Firecracker: Custom microVM hypervisor enabling sub-150ms isolated serverless boots at massive scale.