Question

Difficulty: MediumMessage-Based Integration using Amazon SQS and SNS

A developer is building a serverless integration where an AWS Lambda function with a timeout of 1010 seconds processes messages from an Amazon SQS FIFO queue containing inventory updates. The system must guarantee that updates for the same product are processed in the order they are received, and messages should not be processed multiple times due to timeout discrepancies.

Which of the following configurations should the developer implement to meet these requirements? (Select TWO.)

  1. Set the MessageGroupId of each message to the product ID to ensure sequential processing per product.Answer
  2. Set the SQS queue's visibility timeout to 6060 seconds or more to align with the Lambda function's timeout.Answer
  3. C
    Set the SQS queue's visibility timeout to 55 seconds to ensure that unprocessed messages are quickly retried.
  4. D
    Set the Lambda function's timeout to 6060 seconds while keeping the SQS queue's visibility timeout at 3030 seconds to allow the function more time to complete.
  5. E
    Hardcode the AWS access keys within the Lambda function code to instantiate the SQS client.

Answer

Setting the MessageGroupId to the product ID and configuring the SQS queue's visibility timeout to 6060 seconds or more.
To guarantee sequential processing of messages for the same product, the messages must belong to the same message group, which is achieved by setting the MessageGroupId parameter to the product ID. Additionally, to prevent duplicate message processing when integrating SQS with AWS Lambda, the queue's visibility timeout must be configured to at least 66 times the Lambda function's timeout. Since the Lambda function has a timeout of 1010 seconds, the visibility timeout must be set to 6060 seconds or more.

Step-by-Step Solution

1
Determine the parameter required for message ordering in Amazon SQS FIFO queues.
Identify that the MessageGroupId parameter must be set to group related messages (e.g., by product ID) for sequential processing.
SQS FIFO queues guarantee in-order delivery within a message group, so setting the MessageGroupId to the product ID ensures updates for that product are processed sequentially.
2
Calculate the recommended SQS visibility timeout based on the Lambda function timeout.
Multiply the 1010-second Lambda timeout by 66, yielding 6060 seconds.
AWS Lambda best practices recommend setting the SQS queue's visibility timeout to at least 66 times the function's timeout to prevent concurrent processing of the same message during retries or delays.

Key Concept

Configuring SQS FIFO queues and visibility timeouts for reliable AWS Lambda integration.
Estimated Time:1m 30s
Rate this question