alexcasalboni / aws-lambda-power-tuning

AWS Lambda Power Tuning is an open-source tool that can help you visualize and fine-tune the memory/power configuration of Lambda functions. It runs in your own AWS account - powered by AWS Step Functions - and it supports three optimization strategies: cost, speed, and balanced.
Apache License 2.0
5.4k stars 372 forks source link

Missing num error while executing state machine #237

Closed gaurav-eagleview closed 6 months ago

gaurav-eagleview commented 7 months ago

We executed the state machine with the following input: { "lambdaARN": "arn:aws:lambda:us-east-2:356071293939:function:test_lambda", "powerValues": [ 128, 256 ], "num": 2, "payload": {} }

and got the below error in the initializer:

"error": { "Error": "Error", "Cause": "{\"errorType\":\"Error\",\"errorMessage\":\"Missing num or num below 5\",\"trace\":[\"Error: Missing num or num below 5\",\" at validateInput (/var/task/initializer.js:52:15)\",\" at module.exports.handler (/var/task/initializer.js:14:5)\",\" at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1173:29)\"]}"

Screenshot 2024-03-07 at 10 25 09 PM

What can be the probable cause of it?

tbruccoleri commented 7 months ago

@gaurav-eagleview You'll need to use a number greater than 5, the current value you have is 2.

https://github.com/alexcasalboni/aws-lambda-power-tuning/blob/6272a6b5d8bfee95365899e3b64c243ca00b769f/lambda/initializer.js#L51

alexcasalboni commented 7 months ago

@gaurav-eagleview @tbruccoleri correct :)

As for the error message in the stack trace: "Error: Missing num or num below 5".

I know this might sound like a meaningless error, but the reasoning is that if the number of invocation is too small you will not get statistically relevant results. I'd usually recommend num>=50 to make sure the average invocation time & cost are useful to take an optimal decision.

gaurav-eagleview commented 6 months ago

@alexcasalboni @tbruccoleri : Thanks for the quick support. I understood now. It worked like a charm now :)

gaurav-eagleview commented 6 months ago

Closing this