Using AWS Lambda with Amazon Kinesis for Real-time Data Processing

Instruction: Describe how to process real-time streaming data using AWS Lambda and Amazon Kinesis.

Context: This question evaluates the candidate's experience with integrating AWS Lambda with Amazon Kinesis for real-time data processing, focusing on their understanding of stream-based data architectures.

Updated

Official answer

Create a Kinesis Data Streams event source mapping for the Lambda consumer, with a deliberate starting position, batch size and batching window. Choose standard shared throughput or an enhanced fan-out consumer based on latency, competing readers and cost.

The mapping invokes Lambda with a batch from a shard. There is no total chronological order across all shards. With increased parallelization, ordering is maintained at the partition-key level under the documented producer aggregation constraints. A producer's event timestamp also need not match arrival order. Avoid a hot partition key that concentrates traffic on one shard.

Process records idempotently: retries can deliver records more than once. A failed batch can stall subsequent progress on the affected shard. Configure bounded retry/record-age policy, batch bisection or supported partial batch reporting, and a destination for discarded records. Preserve enough identity and payload information for a deliberate replay; do not silently acknowledge a record whose required side effect failed.

Monitor Lambda IteratorAge, errors and throttles together with Kinesis read/write capacity and downstream saturation. Increase shards or parallelization only when the bottleneck and ordering requirements permit it. A larger batch can improve amortized throughput but raises latency and the amount of work affected by a failure.

Kinesis processing and ordering, partial batch failures

Related Questions