A financial services company uses an Amazon SNS topic to publish transaction notifications. One of the subscribers is an Amazon SQS standard queue that triggers an AWS Lambda function to write transaction details to an Amazon DynamoDB table. The Lambda function is configured with a timeout of seconds. The event source mapping is configured with a Batch Size of messages and a Maximum Batching Window (`MaximumBatchingWindowInSeconds`) of seconds. During high-traffic periods, the DynamoDB table experiences temporary write throttling, which in turn causes the Lambda function to be throttled. The developer observes that many transactions are processed and written to the database multiple times, creating duplicate entries. The current Visibility Timeout of the SQS queue is set to seconds. Which of the following is the root cause of these duplicate entries, and what is the correct configuration to resolve the issue?
- The queue's Visibility Timeout is too short, allowing messages to become visible to other function instances while Lambda retries throttled invocations. The developer should increase the SQS queue's Visibility Timeout to at least seconds.Cevap
- BThe Lambda function is experiencing execution context reuse and timing out due to accumulated stateful connection pools. The developer should increase the Lambda timeout to seconds and configure the function to re-initialize the DynamoDB client inside the handler, keeping the queue's Visibility Timeout at seconds.
- CThe Lambda function's DynamoDB SDK client is initialized with hardcoded AWS access keys that expire periodically. When credentials expire, the SDK fails to write and Lambda retries, causing duplicate processing. The developer should remove the hardcoded keys, use the Lambda execution role, and decrease the SQS Visibility Timeout to seconds to match the Lambda timeout.
- DThe Lambda function is deployed in a private subnet without a NAT Gateway or VPC Endpoint to access DynamoDB, causing the database writes to fail silently and trigger retries. The developer should deploy a NAT Gateway in the public subnet and set the queue's Visibility Timeout to seconds, which is the sum of the Lambda timeout and the batching window.