AWS Cloud Architecture•Part 3: Compute, Containers & Serverless (21 - 35)
Lambda Cold Starts & Mitigation Strategies.
In Simple Words: A cold start happens during the Init phase when AWS provisions a new microVM container for your function. How to Mitigate:
- Provisioned Concurrency: Keeps pre-warmed execution environments ready 24/7 for zero cold-start latency.
- Keep deployment packages small (bundle with
esbuild, tree-shake unused dependencies). - Initialize database connection pools and SDK clients outside the handler function so they are reused across invocations.
bash
# Configure Provisioned Concurrency via AWS CLI:
aws lambda put-provisioned-concurrency-config --function-name CheckoutService --qualifier live --provisioned-concurrent-executions 10