Cloud Computing

AWS Lambda cold-start timeouts for VPC-enabled Node.js functions caused by ENI allocation delays

matte_dev
1mo ago
Environment

Environment

AWS Lambda (Node.js 16) functions configured to access RDS in private subnets; each function runs in VPC with no provisioned concurrency. Cold starts occasionally add 5–15s latency and sometimes produce client HTTP timeouts. Functions without VPC run within 200–400ms.

Symptoms

Symptoms

Cold invocations that require a new execution environment take 5–15s before code executes. CloudWatch logs show long delays before init logs; ENI attach and elastic network interface creation events seen in VPC flow logs. Provisioned concurrency reduces occurrences.

Observations

Observations

Problem correlates with scale-up events. NAT Gateway and subnet capacity appear normal; no obvious API throttling. Enabling a small provisioned concurrency reduces timeout frequency but increases cost. Using VPC-type-free architecture removes the extra latency entirely.

Already attempted

Already attempted

Added provisioned concurrency for critical functions (helpful), increased memory allocation (marginal effect), verified subnets have available IP capacity, created VPC endpoints for S3/API calls—no direct improvement for ENI attach time.

Question

Question

How to reduce cold-start delays for VPC-enabled Lambdas without large cost increases? Are there configuration or architectural changes to avoid ENI attach latency?

COMMUNITY RESPONSES

Verified community troubleshooting

0 replies

No answers yet..

Showing 0 of 0 community responses
AI DIAGNOSTICS

Incident analysis

Updated 1mo ago• Trouble ID

Most likely causes

ENI creation/attachment for VPC-enabled Lambda cold starts 90%
Subnet IP capacity or cross-AZ provisioning constraints causing delayed ENI allocation 40%
NAT gateway or VPC endpoint saturation introducing slowness during init 30%

Summary

Primary cause: when a Lambda configured for VPC needs a new execution environment, AWS must attach/prepare ENIs in the configured subnets which introduces seconds of latency. Using provisioned concurrency keeps execution environments (and ENIs) warm, eliminating ENI setup delay; removing the need for a VPC (or avoiding direct DB access) also eliminates the ENI overhead. Less likely causes are subnet IP exhaustion or NAT gateway saturation; those would show resource alarms, which are not observed here. Evidence: non‑VPC functions do not show delay and provisioned concurrency reduces the issue.

Suggested Fixes

Diagnostic step 1
Short term: enable provisioned concurrency for latency-sensitive functions (keeps ENIs warm).
Diagnostic step 2
Medium term: remove Lambda from VPC where possible; use RDS Proxy, AWS PrivateLink, or a network-facing microservice inside the VPC that Lambdas call to avoid per-function ENI creation.
Diagnostic step 3
Validate subnets have ample available IPs across AZs and ensure NAT gateway/ENI quotas aren't being hit (AWS Console VPC metrics).