Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Lambda Limits when processing Kinesis Stream

Can someone explain what happens to events when a Lambda is subscribed to Kinesis item create events. There is a limit of 100 concurrent requests for an account in AWS, so if 1,000,000 items are added to kinesis how are the events handled, are they queued up for the next available concurrent lambda?

like image 856
Ryan Fisch Avatar asked Aug 14 '15 18:08

Ryan Fisch


People also ask

How many records can Lambda process?

Lambda can process up to 10 batches in each shard simultaneously.

Can Lambda write to Kinesis data stream?

The only other thing to note is that the lambdas obviously need permission to read and write to kinesis. I took the easy option and extended the default lambda-execution-role to allow all access to kinesis but again in a production system you would want to nail this down to very specific permissions.

Can a Lambda listen to multiple Kinesis streams?

If you have one kinesis stream, you can connect as many lambda functions as you want through an event source mapping. All functions will run simultaneously and fully independent of each other and will constantly be invoked if new records arrive in the stream. The number of shards does not matter.

What happens when Kinesis throttled?

Kinesis metrics record only successful operations on the stream. Therefore, operations that are throttled might not be ingested into the Kinesis data stream. This can result in a breach of stream limits and throttling without any metric indications.


1 Answers

From the FAQ http://aws.amazon.com/lambda/faqs/

"Q: How does AWS Lambda process data from Amazon Kinesis streams and Amazon DynamoDB Streams? The Amazon Kinesis and DynamoDB Streams records sent to your AWS Lambda function are strictly serialized, per shard. This means that if you put two records in the same shard, Lambda guarantees that your Lambda function will be successfully invoked with the first record before it is invoked with the second record. If the invocation for one record times out, is throttled, or encounters any other error, Lambda will retry until it succeeds (or the record reaches its 24-hour expiration) before moving on to the next record. The ordering of records across different shards is not guaranteed, and processing of each shard happens in parallel."

What this means is if you have 1M items added to Kinesis, but only one shard, the throttle doesn't matter - you will only have one Lambda function instance reading off that shard in serial, based on the batch size you specified. The more shards you have, the more concurrent invocations your function will see. If you have a stream with > 100 shards, the account limit you mention can be easily increased to whatever you need it to be through AWS customer support. More details here. http://docs.aws.amazon.com/lambda/latest/dg/limits.html

hope that helps!

like image 116
Ajay-AWS Avatar answered Sep 24 '22 06:09

Ajay-AWS