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 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 seconds. Which configuration change should the developer make to resolve this issue?
- Increase the timeout of the Lambda function and decrease the BatchSize in the Kinesis event source mapping.Cevap
- BDeploy the Lambda function in a public VPC subnet and enable public IP assignment to route traffic directly.
- CInitialize the AWS SDK client inside the function handler using hardcoded IAM access keys to bypass credential resolution.
- DModify the upstream transaction ingestion application to use a static partition key for all records to write to a single shard.
Cevap
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.
Adım Adım Çözüm
Anahtar Kavram
Lambda integration with Kinesis Data Streams and execution timeout handling
Tahmini Süre:1m 30s