A developer is building an order processing system. A frontend application publishes order events to an Amazon SNS FIFO topic. An Amazon SQS FIFO queue is subscribed to the topic. An AWS Lambda function is configured to process messages from the queue. The Lambda function has a timeout of seconds.
During testing under heavy load, the developer notices two issues:
1. Some orders are processed multiple times by different Lambda invocations even though the Lambda function executes successfully without errors.
2. Multiple distinct orders submitted by the same customer in rapid succession are being discarded by the SQS FIFO queue.
Which TWO actions should the developer take to resolve these issues?
- Modify the publisher application to construct the MessageDeduplicationId using a combination of the customer ID and a unique order ID, rather than using only the customer ID.Cevap
- Set the Amazon SQS queue's visibility timeout to a value that is at least times the Lambda function timeout, such as seconds.Cevap
- CIncrease the Lambda function's execution timeout to seconds to give it more time to process batches without changing the SQS queue settings.
- DConfigure a unique partition key for each customer on the SQS FIFO queue to distribute the processing load across multiple consumers.
- EHardcode the AWS Access Key ID and Secret Access Key of a policy-restricted IAM user in the Lambda function initialization code to initialize the SQS client.
Cevap
Modify the publisher application to construct the MessageDeduplicationId using a combination of the customer ID and a unique order ID, and set the Amazon SQS queue's visibility timeout to a value that is at least times the Lambda function timeout.
To resolve the duplicate processing issue, the SQS visibility timeout must be at least times the Lambda function timeout ( seconds) so that active executions have ample time to finish and delete messages before they are made visible to other consumers. To resolve the discarded orders issue, the MessageDeduplicationId must be uniquely constructed using a combination of customer ID and order ID rather than just the customer ID, ensuring distinct messages are not incorrectly filtered out during the -minute deduplication window.
Adım Adım Çözüm
Anahtar Kavram
Managing SQS visibility timeout relative to Lambda timeouts and configuring proper MessageDeduplicationId for SQS FIFO queues.