-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(cli): hotswap results in many call to ListStackResources of cloudformation API (with ThrottlingException) #19021
Comments
Hey @JPLemelin, thanks for opening the issue. Is there any chance you can show us some of your CDK and runtime Lambda code? It will make it much easier to reproduce the issue locally. Thanks, |
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
@skinny85, I added a repo here https://github.com/JPLemelin/aws-cdk-issue-19021 In the repo I also add a cloud-trail export https://github.com/JPLemelin/aws-cdk-issue-19021/blob/master/doc/cloudtrail_event_history.json Let's me know if you need more Information! |
Thanks, that's super helpful! I'll be diving into this today. |
@JPLemelin actually, I ran into a problem 😛. Did you forget to include some code in your example app? I see this code in your CDK app: https://github.com/JPLemelin/aws-cdk-issue-19021/blob/6f115b8a97ce407eae2c7d35b614c63bd8fdf69f/lib/aws-cdk-issue-19021-stack.ts#L13, but the code does not contain a
|
In the `LazyListStackResources` class, we were incorrectly caching the results of the ListStackResources CloudFormation API call. This resulted in executing redundant calls, and very visibly impacted the performance of hotswapping when the Stack included many resources. In manual testing, this change brought down deployment time of a large Stack from 80 to 7 seconds. Closes aws#19021
Nvm, figured it out, PR has been opened with a fix 🙂. |
My bad, the |
No worries 🙂. BTW - your setup with having to pass a The idiomatic way is just to have 2 Stacks: new AwsCdkIssue19021Stack(app, 'AwsCdkIssue19021StackDev', {
env: {
region: 'ca-central-1',
account: 'abc',
},
});
new AwsCdkIssue19021Stack(app, 'AwsCdkIssue19021StackProd', {
env: {
region: 'ca-central-1',
account: 'xyz',
},
}); More details: https://www.endoflineblog.com/cdk-tips-05-have-a-stack-instance-per-deployed-stack. |
…9081) In the `LazyListStackResources` class, we were incorrectly caching the results of the ListStackResources CloudFormation API call. This resulted in executing redundant calls, and very visibly impacted the performance of hotswapping when the Stack included many resources. In manual testing, this change brought down deployment time of a large Stack from 80 to 7 seconds. Closes #19021 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
What is the problem?
We are using the hot-swap with lambda code change (
cdk deploy --hotswap my-stack-with-lambda-functions --exclusively
) .Currently the stack have 68 lambdas, who are all using the same code asset, but with different entry point.
The problem we are facing is, the process take almost the exact same time of cloudformation deploy, i.e around 5-6mins 🥲
Reproduction Steps
Have a stack with many lambda, in my case 68 lambda
What did you expect to happen?
Only one call to
ListStackResources
of cloudformation API (or more if paged)What actually happened?
Foreach lambdas, a
ListStackResources
of cloudformation API are done and some hit theThrottlingException
CDK CLI Version
2.12.0
Framework Version
No response
Node.js Version
14
OS
MacOs
Language
Typescript
Language Version
No response
Other information
Hi!
We are using the hot-swap with lambda code change (
cdk deploy --hotswap my-stack-with-lambda-functions --exclusively
) .Currently the stack have 68 lambdas, who are all using the same code asset, but with different entry point.
The problem we are facing is, the process take almost the exact same time of cloudformation deploy, i.e around 5-6mins 🥲
After some investigation we found the cdk do some (many many many 🙃) api call to cloudforamtion on
ListStackResources
, who take around 5mins.On the 876 call to
ListStackResources
, 604 end withThrottlingException
:Rate exceeded
On first few second there are 68 call (same number of lambda) to ListStackResources who don’t have
nextToken
parameter, I think it’s the first call to ListStackResources, other call have a paging parameters (nextTokenaws-cdk/packages/aws-cdk/lib/api/evaluate-cloudformation-template.ts
Line 28 in 9858002
So most of the hot-swap execution time is spent doing
ListStackResources
Our cloudformation stack have 359 ressources
When we use the cli,
aws cloudformation list-stack-resources --stack-name my-stack-with-lambda-functions
, we did not hit any pagingI also add some screen shot from cloudtrail of CDK call during the hot-swap
The text was updated successfully, but these errors were encountered: