Does AWS Lambda process DynamoDB stream events strictly in order?

巧了我就是萌 提交于 2019-12-09 23:14:34

问题


I'm in the process of writing a Lambda function that processes items from a DynamoDB stream.

I thought part of the point behind Lambda was that if I have a large burst of events, it'll spin up enough instances to get through them concurrently, rather than feeding them sequentially through a single instance. As long as two events have a different key, I am fine with them being processed out of order.

However, I just read this page on Understanding Retry Behavior, which says:

For stream-based event sources (Amazon Kinesis Data Streams and DynamoDB streams), AWS Lambda polls your stream and invokes your Lambda function. Therefore, if a Lambda function fails, AWS Lambda attempts to process the erring batch of records until the time the data expires, which can be up to seven days for Amazon Kinesis Data Streams. The exception is treated as blocking, and AWS Lambda will not read any new records from the stream until the failed batch of records either expires or processed successfully. This ensures that AWS Lambda processes the stream events in order.

Does "AWS Lambda processes the stream events in order" mean Lambda cannot process multiple events concurrently? Is there any way to have it process events from distinct keys concurrently?


回答1:


Stream records are organized into groups, or shards.

According to Lambda documentation, the concurrency is achieved on shard-level. Within each shard, the stream events are processed in order.

Stream-based event sources : for Lambda functions that process Kinesis or DynamoDB streams the number of shards is the unit of concurrency. If your stream has 100 active shards, there will be at most 100 Lambda function invocations running concurrently. This is because Lambda processes each shard’s events in sequence.

And according to Limits in DynamoDB,

Do not allow more than two processes to read from the same DynamoDB Streams shard at the same time. Exceeding this limit can result in request throttling.



来源:https://stackoverflow.com/questions/50007896/does-aws-lambda-process-dynamodb-stream-events-strictly-in-order

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!