Soru

Zorluk: OrtaMessage-Based Integration using Amazon SQS and SNS

An application publishes transaction events to an Amazon SNS topic. An Amazon SQS standard queue is subscribed to this topic, and an AWS Lambda function processes messages from the queue. The Lambda function's timeout is configured to 3030 seconds. During traffic spikes, some transactions are processed multiple times by different Lambda invocations, causing duplicate database entries. Additionally, the developer wants to ensure that any messages that fail processing 33 times are automatically moved to a dead-letter queue (DLQ).

Which two actions should the developer take to meet these requirements? (Select TWO.)

  1. Increase the Amazon SQS queue's visibility timeout to at least 180180 seconds.Cevap
  2. Configure a redrive policy on the source Amazon SQS queue specifying a dead-letter queue with a `maxReceiveCount` set to 33.Cevap
  3. C
    Configure a dead-letter queue target on the AWS Lambda function's asynchronous invocation configuration.
  4. D
    Decrease the Amazon SQS queue's visibility timeout to 1010 seconds to speed up the recovery of failed messages.
  5. E
    Set the Amazon SQS queue's visibility timeout to exactly 3030 seconds to align with the Lambda function's timeout.

Cevap

Increase the Amazon SQS queue's visibility timeout to at least 180180 seconds and configure a redrive policy on the source Amazon SQS queue with a `maxReceiveCount` set to 33.
To resolve duplicate processing, the SQS visibility timeout must be configured to at least 66 times the Lambda function's timeout (6×30 seconds=180 seconds6 \times 30\text{ seconds} = 180\text{ seconds}). This ensures the message remains hidden during execution and potential retries. To redirect failed messages after 33 attempts, a redrive policy with `maxReceiveCount` set to 33 must be configured directly on the source SQS queue because the event source mapping invokes Lambda synchronously.

Adım Adım Çözüm

1
Calculate the required visibility timeout for the Amazon SQS queue based on the Lambda function's timeout.
The minimum recommended visibility timeout is 6×30 seconds=180 seconds6 \times 30\text{ seconds} = 180\text{ seconds}.
AWS recommends setting the SQS queue visibility timeout to at least 66 times the Lambda function timeout to allow sufficient time for processing and retries within the event source mapping.
2
Select the correct mechanism to route persistently failing messages to a dead-letter queue (DLQ).
Configure a redrive policy on the source Amazon SQS queue with `maxReceiveCount` set to 33.
Since the Lambda service polls SQS synchronously using event source mapping, DLQ redirection must be configured on the SQS queue itself via a redrive policy, rather than on the Lambda function's asynchronous settings.

Anahtar Kavram

Decoupling serverless architectures using Amazon SNS, SQS, and AWS Lambda event source mappings, including proper visibility timeout alignment and redrive policy configuration.
Bu soruyu puanla