-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Rate exceeded #3821
Comments
I assume that you do not hit an AWS resource limit, but hit the standard AWS REST API request limit (i.e. the amount of concurrently submitted requests to the AWS CloudFormation REST API). Internally that should be visible by the API call returning a 429 (too many requests). To solve such issues the API calls should be serialized properly and each one should wait for the previous one to succeed or fail. Submitting all requests to resolve the 8 cf variable references at once is imo likely to lead to that condition. /cc @eahefnawy |
@StephanPraetsch interesting. Thanks for reporting 👍 and thanks @HyperBrain thanks for jumping in 👍 The But yes, we should definitely do smth. about this since this could be a common problem when heavily using the |
+1 having the same issue with 3 |
Thanks for confirming @hassankhan 👍 Interesting to see that (only) 3 usages of /cc @eahefnawy |
Yep, I unfortunately could not deploy at all so I've hardcoded some values for the moment 🤢 |
🤔 what about using |
Doh! Silly me, completely forgot about those, I'll give that a go!! Much appreciated, @pmuens 😍 |
Great! That should do the trick for no. Furthermore that should give you more security cross-referencing your stacks. We'll investigate in this one and try to fix it so you can switch back to |
@pmuens, Ran into this same issue on my end and implemented a solution similar to what exists here
My solution simply checks for statusCode 400, which is the status code returned when the 'Rate Exceeded' error is thrown. I'll open a PR to include it when I get home today. @HyperBrain's solution of serializing the requests sounds like the ideal way to go but I'm not sure how to implement that at this time. Is there on-going conversation around implementing that solution? |
Hi, I also receive this error however with only one ${cf:} variable (for a user pool which I assign to a custom variable that is then referenced as the authorizer for each lambda function). I can't use Fn::ImportValue for this presumably because sls needs the value for the authorizer at the time of packaging. It seems that each time a custom variable is referenced sls retrieves the value from aws. Also if you have multiple variables in an object that reference ${cf:} vars, then any time you reference that object it looks like all of the ${cf:} variables inside that object are retrieved. This obviously can quickly lead to a lot of requests and the corresponding 'Rate exceeded' error (I can get it with just one ${cf:} variable that is referenced a lot). My testing suggests I can get between 21-23 aws requests in quick succession before getting the rate exceeded error. My quick solution was to change the code in Variables.getValueFromCf to return a cached promise if the variable had already been requested, i.e.:
|
Thanks for commenting @ubaniabalogun and @stevearoonie 👍
Would be great if we could implement such a fix! PRs are always highly welcomed! |
Hi @pmuens, Actually I encounter the exact same issue using ${ssm:/path/to/param} to set environment variables from AWS Parameters Store. I think the fix should be wider than just "Only request CloudFormation variables once". BTW, does someone have a workaround to still deploy from SSM? Thank you all. |
@pmuens I think it is time to do the serialized requests now. @gozup 's issue clearly shows that this will be the only way to eliminate the problem forever. Every other approach that still allows to break the limit of parallel AWS REST API accesses is not really a solution 😃 but merely a workaround that will make the problem more obscure with each PR.
I think the right place would be the API request method itself, as it is used centrally from every location of the framework. It could be handled by using a promised queue which just queues submitted method call promises (I think a proper module was UPDATE: |
I digged into this issue, and it's actully due to a lot of unexpected calls to SSM api. Let me explain: My serverless service count 7 functions and each has 13 environment variable set with SSM. I've added a counter in the function And, well... it makes 442 requests to AWS SSM API before getting the error "Rate exceeded". Meaning 34 requests PER declared SSM parameter... I'm not sure that is the expected behavior. Best |
Ooops 😮 . This doesn't sound healthy, that's an average of roughly 5 calls per var (in each function). @pmuens @eahefnawy Any thoughts? This looks like the variable resolution might not be deterministic and limited. |
And it coud be probably more, since the process is stopped by reaching the rate limit! UPDATE : Cheers, |
Hey @HyperBrain, I've developed a plugin to workaround the SSM issue. However I got a question. Inside my plugin, if I do a If my serverless.yml is set like this : ...
service: my-service
custom: ${file(./environments/serverless/${env:NODE_ENV}.yml)}
plugins:
- serverless-ssm-fetch
... then a Actually it's the last blocker I meet before running live my plugin. Do you have a solution for this? Cheers |
Good catch @gozup 👍 Yes, @HyperBrain AFAIK we have the same issue with the It would be nice if we could "queue and batch" the requests somehow. AFAIR we've discusses such a behavior in one issue (couldn't find the correct reference right now) 🤔 Edit: Hahaha. I finally found the reference. Here you go: #3821 (comment) 😂 |
@gozup Hmmm... Normally |
I use it in To sum up, if I'm very close from the goal, but this last part definitely blocks me :( Thank you mate. |
Did you try if it gets resolved, if you have the file reference in a sub-property of custom instead of custom itself? If it did not work in general, we'd have LOTS of bug reports. Maybe the bug is exactly that importing "custom" from a file does not work. |
Actually, it's a question of async. |
Ok. Then this is a severe bug in the variable resolution part of Serverless. Upon invocation of the lifecycles it MUST be guaranteed that the whole serverless.yml file is resolved with each of its variables that it contains as well as any references that there may be. @horike37 @pmuens @RafalWilinski We should open a separate issue for that with high priority. #3821 (comment) shows clearly that there is a bug. We have to make sure that the variable resolution finishes (and SLS waits for that) and only then continues to start the command lifecycles. |
Hi @pmuens, @HyperBrain, @horike37, @RafalWilinski, FYI, I just did a pull request of my plugin to handle SSM parameters in the meantime. Hope it helps. Cheers, |
@gozup |
@serverless/framework-maintainers @e-e-e I'll finish the actual request caching in the PR linked above. Then we should have killed the rate exceeded eventually. |
@HyperBrain awesome. Thanks for letting me know. Although I thought the solution was to implement a rate limited promise queue on the provider rather than a cache. As if you don’t queue the requests, we will still end up with the possible scenario where X (any large number) calls are made in parallel and 💥. |
@e-e-e Oh, you're right. I'll change the code to cache the request promise instead of the received value. That's an easy thing. |
The complementing PR is finished now. I'd appreciate if people in this thread would test out the |
Do you mean, with this new feature, I needn't use export variables any more, right? Because when implemented with export variables, I found the cloudformation stacks go with chain, and I can't delete stackA directly, because it has several export variables referenced by stackB. And |
@ozbillwang Yes. With this fix, referencing variables with |
I am facing the same issue. My deploy command:
NOTE: Also, removing --aws-s3-accelerate does not work. |
Seems to be happypack package the problem. I am thinking about CircleCI resources exceed (CPU maybe?) |
Well... The error comes back again, even without happypack. Thoughts? |
@brunocascio Is there an exact version of Serverless where it reappeared - or what is the last working one? |
Hi @HyperBrain, thanks for the quick response. I believe that I'm facing this issue since 1.26.x. I am using circleCI in order to deploy the api but I tried again and it works. Sometimes it works, sometimes it doesn't. Perhaps, could be a CircleCI error because in local environment works pretty well, BUT, I'm using different IAM credentials for circleCI, so could be a limit of AWS resources usage, |
Good point. Can you check if some permissions in that area are different or missing in the CI user role? |
Even using administrator access I got this error. |
Oh, wait. The Rate Exceeded fix I did (which closed this task) only affects any implementation that internally uses the Serverless.provider.request() method. I think the S3 upload/download functions might bypass this (especially after the acceleration has been added). So it might not be resolvable right now, but at least is restricted to this use case. Of yourse this does not help you 🤔 . We should open a separate bug that explicitly states the dependency on S3 / acceleration as it is different than this issue. |
Cool! Let me a few builds without using |
Well... Even removing |
I used to have this issue, but after v1.25, I don't have it any more. Yesterday, I re-run the codes in exist and a totally new aws accounts, both works fine with latest sls version. I am not sure the problem you have, but this is my feedback I can give. I didn't use the option Can you try this, remove the whole stack and deploy it again? |
I removed .cache folder from node_modules and it seems to work. The error appears sometimes.. In a few days I'll back to comment |
It does not work... I'm thinking about
Might be related with: serverless-heaven/serverless-webpack#299 |
@brunobelotti "Rate exceeded" must originate from Serverless' deployment phase (uploading the artifacts and calling the CF deployment) as serverless-webpack only does its work during the package phase (where no external interaction is involved). So any plugin that hooks into the deployment phase is a candidate as well as Serverless itself. The error is catched by Serverless' exception handler, so I think it is an AWS call. FYI (different topic): I saw that you use yarn to deploy (and probably setup the node_modules folder). Serverless as well as any released serverless-webpack versions use npm for packaging and might mess up the dependencies installed with yarn - and they do not respect any yarn lock file. |
I've just updated webpack and set SLS_DEBUG. The error could be related with serverless-plugin-split-stacks plugin, but I don't know what's happening...
Thanks for your help! |
You're welcome 😄 . Yes, according to the stack it's there. |
I used |
@brunocascio @HyperBrain I approached very same issue on my side, and proposed some general fix for recoverable request errors here: #4877 (on my side works like a charm) |
@medikoo Sound Great! I was facing that issue sometimes. |
Description
I have 8 times ${cf:..} in my serverless.yaml and I get 3 out of 5 times "Rate exceeded" while running serverless. I suppose I've reached a limit for cloudformation's API calls (DescribeStack for instance). Is there any chance to avoid this error except of increase my limits? Why doesn't serverless calls the api only once for all stacks? Or at least only once per stack?
Last but not least: Which limit do I reach? I don't know which one mentiond on aws limits
For bug reports:
I run "serverless deploy -v" and I get an error "Rate exceeded"
deploying without that error
For feature proposals:
Similar or dependent issues:
Additional Data
The text was updated successfully, but these errors were encountered: