A developer has configured an Amazon Kinesis Data Stream with 5 shards. A Lambda function is consuming events from this stream. Recently, the developer noticed that the 'IteratorAgeMilliseconds' metric for the Lambda function consuming from this stream is steadily increasing, reaching several hours. The Lambda function's 'Errors' and 'Throttles' metrics are low, and its invocation duration is stable and low (under 100ms). What is the MOST likely cause of the increasing 'IteratorAgeMilliseconds'?
- AThe Kinesis Data Stream is experiencing high write throughput, exceeding its capacity.
- BThe Kinesis Data Stream has insufficient shards to handle the incoming data volume.
- CThe Lambda function's batch size configured for the Kinesis event source mapping is too small.
- DThe Lambda function is not processing events fast enough, even though its duration is low.
Show answer & explanationAnswer & explanation
Correct answer: D. The Lambda function is not processing events fast enough, even though its duration is low.
IteratorAgeMilliseconds increasing means that the consumer (Lambda) is falling behind the producer, indicating that events are being added to the stream faster than they are being processed. While the Lambda's individual invocation duration is low, the problem lies in the *rate* of processing vs. the *rate* of ingestion. This could be due to insufficient concurrency for the Lambda function, or the batch size being too small such that it's not utilizing its invocations efficiently to keep up with the stream.
Why the other options are wrong
- A. High write throughput exceeding capacity would lead to `WriteProvisionedThroughputExceeded` errors, which would be visible in Kinesis metrics, and could cause data loss or rejections, but not directly cause iterator age to climb if the consumer is still processing successfully.
- B. Insufficient shards would primarily cause `WriteProvisionedThroughputExceeded` errors on the producer side, preventing data from being ingested, rather than causing the consumer to fall behind if data is successfully ingested.
- C. A small batch size can contribute to the Lambda falling behind, as it processes fewer records per invocation, but the core issue is the consumer's overall processing rate not keeping up. This is a contributing factor to the broader problem of the function not processing fast enough.
Kinesis IteratorAgeMilliseconds
The `IteratorAgeMilliseconds` metric for an Amazon Kinesis Data Stream consumer (like Lambda) indicates how far behind the consumer is from the tip of the stream. A steadily increasing value means the consumer is falling behind the data producers.
- Measures the age of the last record successfully processed by the consumer.
- High values indicate bottlenecks in consumer processing.
- Can be caused by insufficient consumer concurrency, processing errors, or inefficient batching.
Memory trick: Kinesis Age: If the Iterator is old, the consumer's too slow, or not enough shards to go.