Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Lambda and Kinesis Client Library (KCL)

How come I find so little examples of the KCL being used with AWS Lambda. https://docs.aws.amazon.com/streams/latest/dev/developing-consumers-with-kcl.html

It does provide a fine implementation for keeping track of your position on the stream (checkpointing).

I want to use the KCL as a consumer. My set-up is a stream with multiple shards. On each shard a Lambda is consuming. I want to use the KCL in the Lambda's to track the position of the iterator on the shard.

Why can't I find anyone who use the KCL with Lambda. What is the issue here?

like image 779
xtra Avatar asked Nov 12 '18 18:11

xtra


People also ask

Does Lambda use KCL?

Since you can directly consume from Kinesis in your lambdas (using Kinesis as event source) it doesn't make any sense to use KCL within lambda. The event source framework that AWS has built must be using something like KCL to bring lambdas up in response to kinesis events.

What is KCL in AWS Kinesis?

The KCL acts as an intermediary between your record processing logic and Kinesis Data Streams. The KCL performs the following tasks: Connects to the data stream. Enumerates the shards within the data stream. Uses leases to coordinates shard associations with its workers.

Can Lambda write to Kinesis?

Yes. You can create a Dynamo Trigger backed by a Lambda function, and have that Lambda Function write to a stream.

How does Lambda work with Kinesis?

For standard iterators, Lambda polls each shard in your Kinesis stream for records at a base rate of once per second. When more records are available, Lambda keeps processing batches until the function catches up with the stream. The event source mapping shares read throughput with other consumers of the shard.


1 Answers

Since you can directly consume from Kinesis in your lambdas (using Kinesis as event source) it doesn't make any sense to use KCL within lambda. The event source framework that AWS has built must be using something like KCL to bring lambdas up in response to kinesis events.

It would be super weird to bring up a lambda, initialize KCL in the handler and wait for events during the lambda runtime. Lambda will go down in 5 mins and you'll again do the same thing. Doing this from an EC2 instance makes sense but then you're reimplementing the Lambda - Kinesis integration by yourself. That is what Lambda is, behind the scene.

like image 180
Prateek Avatar answered Sep 16 '22 22:09

Prateek