AWS › Lambda & Serverless

What is a cold start in Lambda, and what strategies help reduce its impact on application performance?

Intermediate

Answer

A cold start occurs when Lambda needs to initialize a brand new execution environment for a function that has not run recently, adding some additional latency compared to a warm invocation that reuses an already initialized environment, and strategies to reduce cold start impact include choosing a lighter weight runtime, minimizing the size of your deployment package and its dependencies, and using Provisioned Concurrency to keep a specified number of execution environments pre initialized and ready to respond immediately.
aws lambda put-provisioned-concurrency-config --function-name my-function --qualifier prod --provisioned-concurrent-executions 5
Real-world example A customer facing API backed by Lambda enables Provisioned Concurrency to keep several execution environments warm at all times, ensuring consistent low latency responses for users even during periods of low traffic when a cold start would otherwise be more likely.

Common follow-ups: How much additional latency does a typical cold start actually add?;What is the cost tradeoff of enabling Provisioned Concurrency compared to accepting occasional cold starts?