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.

When an event arrives and no warm environment is free, the cold start runs in order.

  • Lambda downloads your package or container image.
  • It starts the runtime: the JVM, Node.js or Python.
  • It runs your init code, the code outside the handler.
  • Only then does the handler get the first event.

Key concepts

  • INIT_DURATION
  • Provisioned Concurrency
  • SnapStart
  • Hyperplane ENI
  • Execution Environment Lifecycle

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