March 15, 2025
AWS Lambda Cost Optimization: Memory, Duration, and Concurrency
8 min read
Lambda pricing is based on memory allocation and execution time. Most functions are over-provisioned, leading to unnecessary costs.
We've helped teams reduce Lambda costs by 40% by optimizing memory allocation and reducing cold starts.
Optimization strategies
- Right-size memory: Test different memory settings and pick the one that minimizes cost per request.
- Reduce cold starts: Use provisioned concurrency for critical functions, or switch to containers.
- Optimize code: Reduce execution time by caching dependencies and minimizing I/O.
- Monitor concurrency: High concurrency can trigger throttling and increase costs.
Sonar tracks Lambda costs per function and suggests optimal memory settings based on actual usage.