AWS Certified Developer – Associate — Question 442
A company hosts a microservices application that uses Amazon API Gateway. AWS Lambda, Amazon Simple Queue Service (Amazon SQS), and Amazon
DynamoDB. One of the Lambda functions adds messages to an SQS FIFO queue.
When a developer checks the application logs, the developer finds a few duplicated items in a DynamoDB table. The items were inserted by another polling function that processes messages from the queue.
What is the MOST likely cause of this issue?
Answer options
- A. Write operations on the DynamoDB table are being throttled.
- B. The SQS queue delivered the message to the function more than once.
- C. API Gateway duplicated the message in the SQS queue.
- D. The polling function timeout is greater than the queue visibility timeout.
Correct answer: D
Explanation
If the polling Lambda function's execution timeout is longer than the SQS queue's visibility timeout, a message may become visible again in the queue before the processing function can finish and delete it. This leads to another invocation processing the same message, causing duplicate writes to Amazon DynamoDB. To prevent this, the SQS visibility timeout must always be configured to be greater than the Lambda function's timeout.