DVA-C02 Question 28
Select 2You are developing a serverless application that processes messages from an Amazon SQS queue using an AWS Lambda function. Occasionally, some messages fail to process due to transient issues. To ensure the application remains fault-tolerant while minimizing duplicate processing, which of the following design patterns should you implement?
- A
Enable retries with exponential backoff in the Lambda function's error handling logic.
- B
Configure a Dead-Letter Queue (DLQ) for the SQS queue to capture failed messages after the maximum retry attempts.
- C
Increase the visibility timeout of the SQS queue to avoid multiple Lambda function invocations for the same message.
- D
Enable long polling on the SQS queue to reduce the likelihood of transient errors.
- E
Use AWS Step Functions to orchestrate retries rather than handling them directly in the Lambda function.
Show answer and explanation
Correct answers: A, B
Explanation
Retries with exponential backoff and a Dead-Letter Queue (DLQ) are essential fault-tolerant design patterns in an SQS-Lambda architecture. Exponential backoff helps handle transient errors by delaying retry attempts, while a DLQ ensures that unprocessed messages are not lost, enabling further analysis and debugging. These patterns align with best practices for building resilient serverless applications.
- A. Correct.
Correct: Retries with exponential backoff help handle transient issues by spacing out subsequent retry attempts, reducing the risk of overwhelming the system or retrying during temporary outages.
- B. Correct.
Correct: A Dead-Letter Queue (DLQ) captures messages that fail to process after the maximum retry attempts, allowing you to analyze and handle them separately without losing data.
- C. Incorrect.
Incorrect: Increasing the visibility timeout is not a solution for handling transient issues or ensuring fault tolerance. It is primarily used to prevent multiple consumers from processing the same message simultaneously.
- D. Incorrect.
Incorrect: While long polling reduces the cost and latency of retrieving messages, it does not directly address fault tolerance or handling failed message processing.
- E. Incorrect.
Incorrect: AWS Step Functions can be used for orchestration, but in this scenario, retries and DLQs are more direct and efficient solutions for handling transient errors in an SQS-Lambda setup.