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.29k stars 363 forks source link

ResourceConflictException #167

Closed larry-voicefoundry closed 2 years ago

larry-voicefoundry commented 2 years ago

Hello, I am getting a "ResourceConflictException" error in the state machine when attempting to start the app with the example script (manual cdk deployment).

My execution input (without the actual Lamdba arn): { "lambdaARN": "my-lambda-arn", "powerValues": [128, 256, 512, 3008], "num": 5, "payload": {}, "enableParallel": false, "strategy": "cost" }

Output: {}

I tried setting enableParallel to false to see if that would help as it appears the issue is it is trying to reconfigure the lambda while it is still in the process of updating the last configuration change but that didn't help. Any idea what I might be doing wrong here?

image

alexcasalboni commented 2 years ago

Hi @larry-voicefoundry 👋 thanks for reaching out!

Are you using CDK patterns?

As for #156, I'm aware that the CDK patterns template is referring to an older version of the SAR application. See my open PR here: https://github.com/cdk-patterns/serverless/pull/250

Could you please check which SAR app version are you using in your template?

The latest semantic version is 4.2.0.

Since version 4.0.0, the tool is compatible with the new Lambda state expansion. Basically, the new code wants for every state update to be completed with a proper waiter.

larry-voicefoundry commented 2 years ago

I should have mentioned I saw that issue and already tried to update the SAR version. I originally deployed the app with the version it defaults to. After seeing the open issue, I deleted the stack, upped the version to 4.2.0, and redeployed, but I got the same error.

I have attached the stack file I last deployed with. the-lambda-power-tuner-stack.txt

alexcasalboni commented 2 years ago

Ok cool, thanks for the update. By the way, that PR has finally been merged today 😄

Back to our problem.

Any chance that you're trying to power-tune the same function multiple times in parallel? (as in, running multiple executions of state machine concurrently, on the same function)

If that's not it, let's consider a few more options.

For example, does the same happen if you add aws:states:opt-out to your function's description? (see this article to understand why)

larry-voicefoundry commented 2 years ago

I just realized that after changing the TS file I never re-compiled before redeploying. After running the build and pushing again I no longer have any issues and it works great.

Thank you! This is a great tool and I appreciate all the work you have put into it.

alexcasalboni commented 2 years ago

@larry-voicefoundry cool 🚀 I'm glad we figured it out!

And thanks for using Lambda Power Tuning 🙏