Optimizing Lambda
Functions
on real events
1 - Lambda Performance Basics
Lambda Performance Basics
Memory
- 128 MB to 10.240 MB
- Explicitly configured
CPU
- 1 vCPU for 1.769 MB Memory
- Implicitly configured via memory
2 - Lambda Billing Basics
Lambda Billing Basics
Memory
- xx USD / GB-Second
- Dimensions
- Memory in GB
- Duration in Seconds
Invocations
- xx USD / 1 Million invocations
- Dimensions
- Invocations
Cost
Performance
High memory / Low duration
=
Low memory / High duration
3 - Performance Optimization
Start from the
inside
Optimize code first
Optimizing
Memory
More vCPU can speed up
Increase memory and rerun
3 - Automatic Optimization
AWS Lambda Power Tuning
- Powered by AWS Step Functions
- Customization with Pre/Post-processing Functions
- Allows detailed configuration
- Creates versions and aliases for testing
github.com/alexcasalboni/aws-lambda-power-tuning
Real Events?
Testing Lambdas requiring
changing events
AWS Lambda Live Tuner
- CLI Tool
- Simple / limited configuration
- Testing on real events
- Uses unpublished version or production alias
github.com/janritter/aws-lambda-live-tuner
AWS Lambda Live Tuner - Steps
1. Change memory to the next test value
2. Check the logs for n invocations with the memory value
3. Continue with 1 if not all configurations were tested
4. Reset memory to pre-test value
4 - Tech Demo
?
Q/A
github.com/janritter/aws-lambda-live-tuner
hachyderm.io/@jan0ritter
twitter.com/jan0ritter
janri.de

AWS User Group Cologne - Optimizing Lambda Functions on real events