Skip to content
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

Set Concurrency Limit to 1 in CloudFormation Stack #206

Closed
CarlosCuevas opened this issue Jun 27, 2024 · 9 comments · Fixed by #207
Closed

Set Concurrency Limit to 1 in CloudFormation Stack #206

CarlosCuevas opened this issue Jun 27, 2024 · 9 comments · Fixed by #207
Assignees
Labels
enhancement New feature or request

Comments

@CarlosCuevas
Copy link

CarlosCuevas commented Jun 27, 2024

Is your feature request related to a problem? Please describe.
It's possible to have several instances of the lambda function simultaneously. This could lead to race conditions. I can't imagine any scenario where someone would want multiple executions of the lambda function simultaneously.

Describe the solution you'd like
Set Reserve Concurrency Limit to 1 for the Lambda function within the CloudFormation Stack/AWS Serverless App Repo.

@sdemjanenko
Copy link

Wouldn't that incur costs when the lambda isn't actually executing? Is the problem an issue of locking (where one lambda execution is still running while another execution tries to start)? That could be solved by a locking structure in dynamo DB or potentially with step functions.

@ChrisPates
Copy link
Contributor

ChrisPates commented Jun 27, 2024 via email

@CarlosCuevas
Copy link
Author

CarlosCuevas commented Jun 27, 2024

Wouldn't that incur costs when the lambda isn't actually executing? Is the problem an issue of locking (where one lambda execution is still running while another execution tries to start)?

Yes, sorry. I may have misunderstood what I read. The goal is to block execution while another is in progress.

I t would be modest effort to implement, however it is unlikely to be necessary, in all be very specific combination of circumstances.

We have the lambda function running every x minutes. Every so often an execution will exceed the x number of minutes and there will be > 1 running simultaneously.

Alternatively, we were considering having executions be triggered by changes in Google Workspace (as opposed to being timer based), but that runs the risk of triggering multiple if one is already in progress. Not being able to configure or limit It felt like a footgun.

@CarlosCuevas CarlosCuevas changed the title Set Reserve Concurrency to 1 in CloudFormation Stack Set Concurrency Limit to 1 in CloudFormation Stack Jun 27, 2024
@ChrisPates ChrisPates self-assigned this Jun 28, 2024
@ChrisPates ChrisPates added the enhancement New feature or request label Jun 28, 2024
@CarlosCuevas
Copy link
Author

CarlosCuevas commented Jun 28, 2024

Wouldn't that incur costs when the lambda isn't actually executing?

per https://docs.aws.amazon.com/lambda/latest/dg/provisioned-concurrency.html

Reserved concurrency – This represents the maximum number of concurrent instances allocated to your function. When a function has reserved concurrency, no other function can use that concurrency. Reserved concurrency is useful for ensuring that your most critical functions always have enough concurrency to handle incoming requests. Configuring reserved concurrency for a function incurs no additional charges.

@ChrisPates
Copy link
Contributor

The naming of these properties can be some what confusing.

@ChrisPates ChrisPates linked a pull request Jun 28, 2024 that will close this issue
ChrisPates added a commit that referenced this issue Jun 28, 2024
Issue #, if available:
#206

Description of changes:
Updated the CloudFormation template to hardcode the maximum allowed concurrency for the lambda function to 1. There is no situation under which it would be safe to run more than one instance.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
@philomory
Copy link

philomory commented Nov 6, 2024

I will note, for posterity, that if you create a new account to be the Delegated Administrator for your IAM Identity Center instance, and you install this stack in that new account (or any other freshly created account), then even though the "default" quota for "Concurrent executions" is 1,000, the new account will have a "Concurrent executions" quota of 10. In theory this is supposed to automatically increase up to the "real" default of 1000 over time as you use Lambda, but another quirk of the "Concurrent executions" quota is that you can never have fewer than 10 "unreserved" executions, so, with the "Concurrent executions" limit at 10, deploying this app will fail with the error "Specified ConcurrentExecutions for function decreases account's UnreservedConcurrentExecution below its minimum value of 10".

@maulerjan
Copy link

@philomory running into exactly the same issue. Any workaround?

@philomory
Copy link

@philomory running into exactly the same issue. Any workaround?

Either request a quota increase, wait for it to be granted, and then deploy; or edit the YAML manifest file and set the concurrency to 0; or both (as in, request a quota increase, deploy with a manually edited YAML while waiting for it to be approved, and then edit the YAML back and deploy again)

@maulerjan
Copy link

Thanks! Deploying serverless app from template for the first time, didn't know the yaml could be edited

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants