Lambda Cold Start Latency

Diagnose and eliminate Lambda initialization latency that spikes p99 response times.

Overview

Overview

A Lambda cold start happens when AWS must provision a new execution environment for your function. Your handler only receives the first event after three phases finish: download, runtime start and your init code.

Cold start by runtime

  • Java and Kotlin — Often adds 1–10 seconds — The JVM takes time to start and class-load
  • Node.js and Python — 50–500 milliseconds — Fast enough that users rarely notice
  • Go — Under 100 milliseconds — Runtime compiled into a single binary, no separate interpreter startup

VPC attachment

> [!WARNING] Verify your function uses the newer Hyperplane model: functions created before 2020 may not.

Tools and what each tells you

  • CloudWatch Logs Insights, INIT_DURATION in the REPORT line — Which invocations paid the initialization tax: the field only appears on cold starts
  • AWS X-Ray — Initialization as its own segment before the Invocation segment; the gap is your cold start
  • Lambda Insights (managed layer) — cold_start metrics in CloudWatch, by function name and version

Fixes, by cost and effectiveness

  • Reduce package size — Shortens download: remove dev dependencies, use Lambda layers for shared libraries, prefer tree-shaking bundlers like esbuild — Always worth doing, rarely eliminates the problem
  • Avoid unnecessary VPC attachment — Removes network-interface setup — Only where the function does not need the VPC
  • SnapStart (Java) — Snapshots the initialized JVM after init code runs and restores from it, bringing Java cold starts under 1 second — Free, but only helps Java
  • Provisioned concurrency — Pre-warmed environments that are always ready — Most reliable; charges for idle time, so fits latency-sensitive production, not batch jobs or dev
  • Scheduled pings — Keep an environment warm — Unreliable: Lambda may still start fresh environments

> [!IMPORTANT] The core trade-off is cost versus a latency guarantee.

Key concepts

INIT_DURATION
The time Lambda spent initializing the execution environment, printed in the REPORT log line only on cold starts. Includes download, runtime startup, and init code execution.
Provisioned Concurrency
A Lambda configuration that keeps a specified number of execution environments pre-initialized and ready to respond instantly, eliminating cold starts for those environments at an ongoing hourly cost.
SnapStart
A Java-specific Lambda feature that takes a snapshot of the initialized execution environment after init code completes, then restores from that snapshot on cold starts instead of re-running initialization.
Hyperplane ENI
The shared elastic network interface model AWS introduced to fix VPC cold start latency. Hyperplane ENIs are pre-created and reused across function invocations, removing the per-cold-start ENI attachment delay.
Execution Environment Lifecycle
Lambda environments go through Init, Invoke (one or more times), and Shutdown phases. A cold start only occurs during Init; subsequent invocations reuse the same environment and pay only Invoke time.

When to use it

  • Diagnosing p99 latency spikes that correlate with traffic lulls
  • Explaining Lambda execution model and initialization phases in a system design interview
  • Designing a Lambda-based service that must meet strict latency SLAs

Interview questions

  • A customer-facing Lambda API has p99 latency of 800ms during normal traffic but spikes to 8 seconds after a 5-minute quiet period. How do you diagnose and fix this?
  • Why does enabling VPC for a Lambda function affect cold start times, and how do you determine if the Hyperplane fix applies to your function?

Sign up free to read the full topic

More Troubleshooting topics

Start free on Cariara · Coding problems · System design studio