AWS Lambda now provides a way to control the maximum number of concurrent functions called by Amazon SQS as an event source.
By setting Maximum Concurrency, developers can determine the concurrency of functions processing messages in individual SQS queues, simplifying scalability of serverless applications.
Lambda facilitates the consumption of Amazon SQS events at large scale. A Lambda function subscribes to an SQS queue using event source mapping (ESM). ESM consists of processing instances that poll the message queue and call the Lambda function. The processing instances increase when there are more messages to process and decrease when they encounter errors in the function or when the number of messages in the queue decreases.
Previously, clients that wanted to limit the maximum number of concurrent calls from ESM had to set a reserved concurrency limit that would limit the concurrency used by the function, but at the cost of less constant throughput and message retries due to function limiting. This new control over event source matching directly limits the number of concurrent calls without having to configure reserved concurrency to perform such an action.
Event Source Matching (ESM) allows a Lambda function to subscribe to an SQS queue, scaling according to the number of messages in the queue. The elastic ESM polls the queue for messages and invokes the Lambda function accordingly, with the maximum number of messages to be processed simultaneously determined by the service constraints for both services.
The available concurrency of the function is determined by the difference between the concurrency quota, the total reserved concurrency, and the number of calls currently in progress.
There are no additional charges for using the new function. Developers can set the Maximum Concurrency for Amazon SQS via the console, CLI, SAM, or Lambda SDK, with a minimum supported value of 2 and a maximum supported value of 1000.
Pingback: AWS Lambda Вече Поддържа Максимална Съгласуваност за SQS Като Източник на Събития – DevStyleR