简体   繁体   English

Kinesis流到AWS Lambda

[英]Kinesis stream to AWS lambda

I am currently using DynamoDB streams and looking forward to move to Kinesis streams as I want to gain control over the number of records I like to process from the streams. 我目前正在使用DynamoDB流,并希望转向Kinesis流,因为我想获得对我希望从流中处理的记录数的控制。

I have been reading about Kinesis streams and lambda. 我一直在阅读有关Kinesis流和lambda的信息。 There are many articles about Kinesis streams and EC2's where multiple consumers and KCL etc.. 关于Kinesis流和EC2的文章很多,其中有多个使用者和KCL等。

All I would like to know is, If I go with lambda for Kinesis stream, what is the expected behavior? 我只想知道,如果我使用lambda进行Kinesis stream,预期的行为是什么?

  • Like Dynamo streams, when Kinesis has records in the streams, lambda gets triggered with the bunch of records in the event? 像Dynamo流一样,当Kinesis在流中有记录时,lambda会被事件中的一堆记录触发吗?
  • Whenever there are records in Kinesis stream, Lambda gets triggered and Lambda can go ahead and read the shards to fetch the records and process further. 只要Kinesis流中有记录,Lambda就会被触发,Lambda可以继续读取分片以获取记录并进一步处理。

I am looking for the second option in the above. 我正在寻找上面的第二个选择。 I do not want the lambda to be triggered with set of records but I want to control the amount I read. 我不希望通过记录集来触发lambda,但是我想控制读取的数量。

Could anyone explain how can I gain control of Kinesis streams in Lambda? 谁能解释我如何控制Lambda中的Kinesis流?

You can subscribe a lambda to a Kinesis stream. 您可以为Lambda订阅Kinesis流。 When you subscribe you can specify the batch size, 1 to 1000 as I recall. 订阅后,您可以指定批次大小,如我记得的那样,为1到1000。 The lambda will be invoked for each shard in the stream when there are records available up to the batch size. 当有可用的记录达到批量大小时,将为流中的每个分片调用lambda。 If the lambda errors, (eg returns an error or times out) it will be retried with the same data. 如果lambda错误(例如,返回错误或超时),它将使用相同的数据重试。 It will be retried until it succeeds or the records age out of the stream. 它将重试,直到成功或记录过期。 The lambda will be invoked around once per second per shard if there are records available. 如果有记录,则每个分片每秒将调用一次lambda。 The lambda is invoked with whatever records are available up to the batch size. 该lambda会被可用的任何记录(直到批量大小)调用。

There will be only one concurrent lambda invocation per shard. 每个分片将只有一个并发的lambda调用。 This is to guarantee the ordering of records inside a shard. 这是为了保证碎片内记录的顺序。

Generally the behavior for Kinesis streams is the same as for DynamoDB streams. 通常,Kinesis流的行为与DynamoDB流的行为相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM