Question

Difficulty: MediumDebugging Lambda Execution and Configuration Issues

A developer is troubleshooting an AWS Lambda function that processes transaction data from an Amazon Kinesis Data Stream. The Lambda function is configured with a timeout of 1010 seconds. The developer notices that the Kinesis stream's `GetRecords.IteratorAgeMilliseconds` metric is steadily increasing, and the same transaction records are appearing multiple times in the application logs. The Lambda function's CloudWatch logs indicate that some invocations are terminated after running for 1010 seconds. Which configuration change should the developer make to resolve this issue?

  1. Increase the timeout of the Lambda function and decrease the BatchSize in the Kinesis event source mapping.Answer
  2. B
    Deploy the Lambda function in a public VPC subnet and enable public IP assignment to route traffic directly.
  3. C
    Initialize the AWS SDK client inside the function handler using hardcoded IAM access keys to bypass credential resolution.
  4. D
    Modify the upstream transaction ingestion application to use a static partition key for all records to write to a single shard.

Answer

Increase the timeout of the Lambda function and decrease the BatchSize in the Kinesis event source mapping.
Increasing the Lambda function's timeout configuration allows the function more time to process the batch of records before being terminated. Decreasing the BatchSize reduces the number of records Lambda retrieves in a single invocation, decreasing the total processing time per invocation. Together, these actions ensure that the Lambda function can successfully process each batch within the timeout limit, preventing execution terminations, retries of the same batch, duplicate processing, and a rising IteratorAgeMilliseconds metric.

Step-by-Step Solution

1
Analyze the symptoms from CloudWatch Metrics and logs.
The increasing `IteratorAgeMilliseconds` shows the consumer is falling behind the stream. Invocations terminating at 1010 seconds indicate execution timeouts, which cause the Lambda service to retry the same batch, leading to duplicate processing.
Identifying that the Lambda function is timing out while processing a full batch explains why records are processed repeatedly without advancing the stream pointer.
2
Adjust the Lambda configuration to ensure batches complete within the timeout limits.
Increasing the timeout parameter gives the function more execution headroom. Decreasing the batch size (e.g., from 100100 to 5050 records) reduces the processing time required for each individual invocation.
By resolving the timeout, executions complete successfully, allowing the Lambda service to commit the shard checkpoint and decrease the iterator age.

Key Concept

Lambda integration with Kinesis Data Streams and execution timeout handling
Estimated Time:1m 30s
Rate this question