AWS Lambda是否严格按顺序处理DynamoDB流事件? [英] Does AWS Lambda process DynamoDB stream events strictly in order?

查看:92
本文介绍了AWS Lambda是否严格按顺序处理DynamoDB流事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个Lambda函数来处理DynamoDB流中的项目。

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

我认为Lambda背后的部分意思是,如果我有如果发生大量事件,它将启动足够多的实例以同时通过它们,而不是通过单个实例顺序地提供它们。只要两个事件具有不同的键,就可以对它们进行无序处理。

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:


对于基于流的事件源(Amazon Kinesis数据流和DynamoDB流),AWS Lambda轮询您的流并调用您的Lambda函数。因此,如果Lambda函数失败,则AWS Lambda会尝试处理错误的记录批,直到数据过期为止(对于Amazon Kinesis Data Streams而言,最长为7天)。异常被视为阻塞,并且AWS Lambda不会从流中读取任何新记录,直到失败的记录批过期或成功处理为止。这样可以确保AWS Lambda按顺序处理流事件。

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.

是否 AWS Lambda按顺序处理流事件意味着Lambda无法处理同时发生多个事件?有什么方法可以使其同时处理来自不同键的事件?

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?

推荐答案

流记录被组织为组或碎片。

Stream records are organized into groups, or shards.

根据Lambda 文档,并发是在分片级别实现的。在每个分片中,按顺序处理流事件。

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


基于流的事件源:用于Lambda函数该过程Kinesis
或DynamoDB流传输的碎片数是并发单位。
如果您的流中有100个活动分片,则最多将同时运行100个Lambda
函数调用。这是因为Lambda
按顺序处理每个分片的事件。

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.

并根据 DynamoDB中的限制


不允许同时从同一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.

这篇关于AWS Lambda是否严格按顺序处理DynamoDB流事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆