Header Ads Widget

How does the lambda function knows which Kinesis record has already been fetched?

 In AWS Lambda, when processing records from a Kinesis stream, the Lambda service automatically manages the state of the processing. Each record that is processed successfully is acknowledged, meaning Lambda knows it has been processed and won't be retried. Lambda uses a combination of checkpoints and iterators to keep track of where it left off in processing the stream.


Here's a general overview of how this works:



1. **Iterator**: When Lambda reads records from a Kinesis stream, it uses an iterator to indicate where it is in the stream. This iterator points to a specific position in the stream.


2. **Checkpoints**: As records are successfully processed, Lambda checkpoints the position in the stream up to which it has processed the records. This checkpointing is done internally by Lambda and is not directly visible or configurable by the developer.


3. **Retries**: If a Lambda function fails to process a record (due to an error or timeout, for example), Lambda will automatically retry processing that record. It does this by using the checkpointed position in the stream to re-read records starting from that point.


4. **Concurrency**: Lambda can process multiple shards of a Kinesis stream concurrently. Each shard has its own iterator and checkpoint, so Lambda can process records from multiple shards simultaneously without interference.


5. **Scaling**: Lambda automatically scales based on the incoming stream of records. As the incoming rate of records increases, Lambda can automatically spin up more instances to handle the load, each with its own set of iterators and checkpoints.


Read more 


Overall, Lambda abstracts away much of the complexity of managing state when processing records from a Kinesis stream, allowing developers to focus on writing the processing logic for each record without needing to worry about managing iterators or checkpoints themselves.

Post a Comment

0 Comments