AWS Lambda Power Tuning is a solution provided by AWS that uses Step Functions to test your Lambda function across different memory configurations, helping you determine the optimal power setting for best cost/performance ratio.
🧱 Architecture Overview
Here’s how it works:
- A Step Function runs your Lambda with different memory sizes (128MB → 10GB).
- It collects duration, cost, and performance metrics.
- You get a visual report to decide the best setting.
📦 Prerequisites
AWS CLI configured
AWS SAM CLI installed
Node.js Lambda function ready
Deploy the Lambda Power Tuning Step Function
🧪 Step 1: Deploy Lambda Power Tuning
Clone and deploy using the AWS Serverless Application Repository or SAM:
git clone https://github.com/alexcasalboni/aws-lambda-power-tuning.git
cd aws-lambda-power-tuning
sam deploy --guided
After deploy, take note of the Step Function ARN (e.g. arn:aws:states:us-east-1:123456789012:stateMachine:PowerTuningStateMachine)
🚀 Step 2: Run the Power Tuning
Use the AWS Console or invoke the Step Function programmatically:
{
"lambdaARN": "arn:aws:lambda:us-east-1:123456789012:function:MyFunction",
"powerValues": [128, 256, 512, 1024, 2048],
"num": 10,
"payload": "{}",
"parallelInvocation": true,
"strategy": "cost"
}
Replace with your actual Lambda ARN.
You can start the state machine using AWS Console or CLI:
aws stepfunctions start-execution \
--state-machine-arn arn:aws:states:us-east-1:123456789012:stateMachine:PowerTuningStateMachine \
--input file://input.json
📈 Step 3: Analyze the Results
Once completed, the Step Function execution will provide:
Cost vs performance graphs
Recommendations for optimal memory setting
JSON result with metrics
You’ll be able to visually compare:
Execution time
Memory size
Cost (ms × GB × price)
💡 Bonus Tip: Tune for Strategy
Lambda Power Tuning supports different strategies:
cost
– minimize price
speed
– minimize duration
balanced
– tradeoff
Try different strategies depending on your workload.
Top comments (0)