The first request after idle takes 5 seconds; Lambda logs show "Init Duration: 4512.33 ms".

BeginnerTroubleshootingLatency
Answer

Likely causes → Cold starts: a large deployment package, heavy framework initialization, a VPC-attached function initializing, or loading secrets synchronously at init.

Diagnose → Query CloudWatch Logs Insights:

filter @type = "REPORT" | stats avg(@initDuration), count(@initDuration) by bin(5m)

Fix → Trim dependencies, lazy-load heavy clients, use Provisioned Concurrency for latency-critical functions, or SnapStart for Java.

Prevent → Track cold start rate and init duration per function, and set a package size budget in CI.

All Real-World Interview questions Roadmap: Interview readiness

More on Latency