cloud performance ai_generated true

AWS Lambda function times out or takes 10s+ on first invocation when in VPC

ID: cloud/aws-lambda-vpc-cold-start

Also available as: JSON · Markdown
88%Fix Rate
92%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
any active

Root Cause

Lambda functions in a VPC require ENI (Elastic Network Interface) creation on cold start. Before Hyperplane (2019+), this added 10-30s. Post-Hyperplane it's ~1-2s but still catches people. Provisioned concurrency is the real fix.

generic

Workarounds

  1. 95% success Use Provisioned Concurrency to eliminate cold starts
    aws lambda put-provisioned-concurrency-config --function-name my-func --qualifier prod --provisioned-concurrent-executions 5
  2. 85% success Use Lambda SnapStart (Java) or keep dependencies minimal to reduce init time
    Reduce deployment package size. Use Lambda layers for shared deps. Lazy-load heavy SDKs.
  3. 82% success Use VPC endpoints (PrivateLink) instead of NAT Gateway for AWS service access
    This lets Lambda access S3/DynamoDB/etc without full VPC setup, reducing cold start penalty

Dead Ends

Common approaches that don't work:

  1. Increase Lambda timeout to 5 minutes to handle cold start 78% fail

    Longer timeout masks the problem. Users still experience 10s+ delays on every cold start.

  2. Use a CloudWatch scheduled event to keep Lambda warm 72% fail

    Warming pings only keep 1 concurrent instance warm. Second concurrent request still cold starts.

  3. Remove VPC configuration to eliminate cold start 85% fail

    Function loses access to VPC resources (RDS, ElastiCache, etc.). Defeats the purpose of VPC placement.