DVA-C02 Question 25
Select 3You are developing a serverless application using AWS Lambda to process messages from an Amazon SQS queue. Occasionally, the processing of some messages fails due to transient errors. To ensure fault tolerance and prevent message loss, you need to implement a solution that retries failed messages with exponential backoff and handles messages that cannot be processed after multiple attempts. Which combination of approaches should you use?
- A
Enable the built-in retry mechanism in AWS Lambda and configure a dead-letter queue (DLQ) for the SQS queue.
- B
Implement a custom retry mechanism using an AWS Step Functions workflow with exponential backoff.
- C
Use an Amazon SQS delay queue to introduce a delay before retrying failed messages.
- D
Configure the Maximum Receives setting in the SQS queue policy and route unprocessed messages to a dead-letter queue.
- E
Increase the visibility timeout of the SQS queue to allow more time for processing failed messages before retrying.
Show answer and explanation
Correct answers: A, B, D
Explanation
To design a fault-tolerant system for processing SQS messages with AWS Lambda, you should use a combination of approaches. AWS Lambda's built-in retry mechanism allows for automatic retries in case of transient errors. Implementing a dead-letter queue ensures that messages that cannot be processed after multiple retries are not lost and can be analyzed or reprocessed later. Additionally, using a custom retry mechanism, such as AWS Step Functions with exponential backoff, provides more control over retry policies. The Maximum Receives setting in SQS policies ensures that unprocessed messages are routed to the DLQ after a defined number of attempts, further enhancing fault tolerance.
- A. Correct.
Correct: The built-in retry mechanism in AWS Lambda, combined with a dead-letter queue, ensures that failed messages are retried and unprocessable messages are routed to the DLQ for further analysis.
- B. Correct.
Correct: AWS Step Functions allows you to create a custom retry mechanism with exponential backoff, enabling you to handle transient errors more effectively and improve fault tolerance.
- C. Incorrect.
Incorrect: While delay queues introduce a delay before retrying messages, they do not provide exponential backoff or a mechanism to handle unprocessed messages, making them less suitable for this scenario.
- D. Correct.
Correct: The Maximum Receives setting in SQS policies ensures that messages are routed to a dead-letter queue after a specified number of processing attempts, preventing message loss.
- E. Incorrect.
Incorrect: Increasing the visibility timeout only allows more time for processing messages but does not implement retries or handle unprocessable messages. It does not directly address the requirements for fault tolerance.