Reputation: 42418
I'd like to limit my lambda maximum execution concurrency and I come cross reserved concurrency
which can be used to achieve this goal. However, once I reserve other lambdas won't be able to use the concurrency which I don't want to impact other lambdas.
How can I set a maximum concurrency on my lambda without using reserved
one? I am happy to put a queue e.g. SQS, Dynamodb stream, EventBridge etc. but I can't find a solution from them.
Upvotes: 11
Views: 2320
Reputation: 1843
As of January 2023, Amazon does support limiting maximum concurrency for a Lambda subscribed to an SQS queue. More details are available on this answer to an earlier question specific to Lambda SQS queue consumption.
Upvotes: 1
Reputation: 301
You can set up a FIFO SQS Queue to trigger your Lambda and then control concurrency by carefully assigning MessageGroupId's when you add messages to the queue. See SQS Fifo as an event source.
Upvotes: 0
Reputation: 1208
Since you mentioned you're open to using other services, such as SQS, in-front of Lambda to throttle your function, I would mention another option:
Put an Amazon API Gateway API in front of the Lambda and configure a throttling target, and then handle retries at the client level.
Upvotes: 0
Reputation: 8887
The reserved concurrency is exactly what you need to use for this. If you need more available to other functions you can request an increase from AWS. The limits are soft limits.
Upvotes: 2
Reputation: 238051
How can I set a maximum concurrency on my lambda without using reserved one?
You can't. If you don't want to use reserved concurency, then there is no other way to reliably throttle your function.
You could though set event source mapping between SQS and Lambda, with batch size
of 1 and high Batch window
. But this still does not stop from executing your function "manually", or setting up other triggers for it (sns, event bridge, ...) so that it uses high concurrency.
Upvotes: 2