I have a dynamodb table. Whenever I add a new item to the table, a lambda function is triggered, certain processing is done and the new item is updated. It works fine, but I was wondering what if thousands of items were added at once. Will the function execute for all items at once?? Or will the execution be queued?
3 Answers
From Managing Concurrency, official document for AWS Lambda
Functions scale automatically based on incoming request rate
So, it means that if requests are concurrent then to handle these requests multiple instances of the same function will execute. Some of the requests may be queued.
Also from the same documentation,
By default, AWS Lambda limits the total concurrent executions across all functions within a given region to 1000.
From Understanding Scaling Behavior
For Lambda functions that process Kinesis or DynamoDB streams the number of shards is the unit of concurrency
Amounts of shards depend on your partition key cardinality. For example, if your partition key cardinality is 2, then you have only two shards, and concurrency of your lambda is 2.
Remember you can't control a number of shards explicit. This is a related question