Soru

Zorluk: ZorMessage-Based Integration using Amazon SQS and SNS

A developer is implementing a backend processing system using an Amazon SQS queue and an AWS Lambda function. The Lambda function processes messages in batches and has its timeout configured to 30 seconds. During peak hours, the developer notices that some messages are being processed multiple times by the Lambda function, despite the function successfully completing without errors. The developer also wants to ensure that messages that fail to process after 3 attempts are moved to a dead-letter queue (DLQ). Which two configurations must the developer implement to resolve the duplicate processing issue and properly configure the DLQ? (Choose two.)

  1. Increase the visibility timeout of the SQS queue to at least 180 seconds.Cevap
  2. Define a redrive policy on the source SQS queue that references the DLQ ARN and sets the maxReceiveCount to 3.Cevap
  3. C
    Define a redrive policy on the DLQ that references the source SQS queue ARN and sets the maxReceiveCount to 3.
  4. D
    Increase the SQS queue's visibility timeout to 35 seconds and increase the Lambda function's timeout to 45 seconds.
  5. E
    Configure the SQS queue with a Delivery Delay of 180 seconds to allow Lambda sufficient execution buffer time.

Cevap

Increase the visibility timeout of the SQS queue to at least 180 seconds, and define a redrive policy on the source SQS queue that references the DLQ ARN and sets the maxReceiveCount to 3.
To prevent SQS from returning messages to the queue while a Lambda function is still processing them, the source queue's visibility timeout should be set to at least 6 times the timeout of the Lambda function. Since the Lambda function has a timeout of 30 seconds, the SQS visibility timeout must be configured to at least 180 seconds (6×306 \times 30). Additionally, to configure a dead-letter queue (DLQ) for failed messages, a redrive policy must be defined on the source SQS queue (not the DLQ itself) specifying the target DLQ ARN and a maxReceiveCount of 3.

Adım Adım Çözüm

1
Calculate the recommended SQS visibility timeout based on the Lambda function's timeout.
The visibility timeout should be at least 6 times the Lambda timeout: 6×30=1806 \times 30 = 180 seconds.
This prevents the queue from delivering the message to other consumers while the Lambda function is still processing or retrying.
2
Identify where the redrive policy must be configured for a dead-letter queue (DLQ).
The redrive policy must be configured on the source SQS queue, pointing to the DLQ ARN.
Configuring it on the source queue directs SQS to move messages to the DLQ after the maximum receive count is reached.
3
Set the maxReceiveCount attribute in the redrive policy.
Set maxReceiveCount to 3.
This configuration matches the requirement to send messages to the DLQ after 3 failed processing attempts.

Anahtar Kavram

SQS Visibility Timeout and DLQ Redrive Policy Configuration with Lambda Consumers
Bu soruyu puanla