We reduced a client's serverless AWS bill from $10,200/month to $1,150/month - a 89% reduction - without degrading performance. Here's exactly how.
The Cost Anatomy
Where Serverless Money Goes
- Lambda invocations (35%) - Function execution charges
- API Gateway (25%) - HTTP request processing
- DynamoDB (20%) - Read/write capacity units
- CloudWatch (10%) - Logging and monitoring
- S3 + Data Transfer (10%) - Storage and bandwidth
Optimization Strategies
1. Right-Size Memory Allocation
Lambda pricing scales linearly with memory. Counter-intuitively, more memory often means lower cost because faster execution:
- 128MB: 3,200ms execution = $0.0000067
- 512MB: 800ms execution = $0.0000067
- Same cost, 4x faster response
2. Reduce Invocations
- Batch processing - Process 100 records per invocation instead of 1
- Event filtering - Use EventBridge rules to filter before invoking Lambda
- Caching - CloudFront or API Gateway caching eliminates redundant invocations
3. API Gateway Alternatives
Replace API Gateway ($3.50/million requests) with:
- Lambda Function URLs - Free, direct invocation
- CloudFront Functions - $0.10/million requests for edge logic
- Application Load Balancer - Better for high-throughput APIs
4. DynamoDB Optimization
- Switch from provisioned to on-demand for variable workloads
- Use DAX (DynamoDB Accelerator) for read-heavy patterns
- Implement single-table design to reduce read operations
5. Cold Start Mitigation
- Provisioned concurrency for latency-sensitive functions
- SnapStart for Java Lambda functions (90% cold start reduction)
- Smaller deployment packages - Fewer dependencies = faster cold starts
Real-World Case Study
Before optimization: E-commerce platform, 50M monthly requests
| Service | Monthly Cost |
|---|---|
| Lambda | $3,600 |
| API Gateway | $2,800 |
| DynamoDB | $2,100 |
| CloudWatch | $1,000 |
| Other | $700 |
| Total | $10,200 |
After optimization:
| Change | Savings |
|---|---|
| Lambda Function URLs (replace API Gateway) | -$2,500 |
| Batch processing (reduce invocations 80%) | -$2,900 |
| DynamoDB single-table + caching | -$1,600 |
| CloudWatch log filtering | -$750 |
| Memory right-sizing | -$1,300 |
| New Total | $1,150 |
Need help optimising your cloud costs? Book a free cost review and we'll identify savings.
