A developer is building a serverless application that processes orders. An order is placed and an event is published to an Amazon SNS topic. The SNS topic has multiple subscribers, including an SQS queue for order processing and a Lambda function for sending notifications. The developer wants to ensure that the SQS queue receives all messages reliably, even if the processing Lambda function fails temporarily. Which configuration should the developer set?
Trap 1: Enable SNS delivery retries for HTTP endpoints
Enabling SNS delivery retries for HTTP endpoints is irrelevant when an SQS queue is subscribed to an SNS topic. SNS delivery retries are specifically designed for HTTP/S or other non-queue endpoints where SNS directly attempts to deliver messages to an external service. When SQS is the subscriber, SNS reliably delivers the message to the SQS queue, and the queue itself, along with its consumers like Lambda, manages the subsequent processing and retry logic, not SNS's endpoint-specific retry mechanism.
Trap 2: Set the SQS queue's visibility timeout to a value greater than the…
Setting the SQS queue's visibility timeout to a value greater than the Lambda function's processing time primarily prevents duplicate processing of a message by multiple consumers during a single processing attempt. While a longer timeout allows the Lambda function sufficient time to complete its work and can facilitate retries for transient failures (as the message reappears if not deleted), it does not inherently ensure reliability if a message consistently fails processing due to persistent errors or malformed data, which would still lead to message loss without a DLQ.
Trap 3: Configure the SNS topic to use server-side encryption
Configuring the SNS topic to use server-side encryption (SSE) with AWS KMS protects the confidentiality of messages by encrypting them at rest within the SNS topic and during delivery to encrypted SQS queues. This is a crucial security measure for sensitive data, ensuring that unauthorized parties cannot access message content. However, encryption does not address the operational reliability of message delivery or the ability to recover messages that fail processing, which are distinct concerns from data security.
- A
Enable a dead-letter queue on the SQS queue
Enabling a dead-letter queue (DLQ) on the SQS queue is the correct approach to ensure message reliability in a serverless application. If a Lambda function repeatedly fails to process an order message after exhausting its configured retries, the DLQ captures these unprocessable messages. This prevents data loss by providing a dedicated queue for failed messages, allowing for later inspection, debugging, and potential manual reprocessing, which is critical for maintaining data integrity in order processing.
- B
Enable SNS delivery retries for HTTP endpoints
Why wrong: Enabling SNS delivery retries for HTTP endpoints is irrelevant when an SQS queue is subscribed to an SNS topic. SNS delivery retries are specifically designed for HTTP/S or other non-queue endpoints where SNS directly attempts to deliver messages to an external service. When SQS is the subscriber, SNS reliably delivers the message to the SQS queue, and the queue itself, along with its consumers like Lambda, manages the subsequent processing and retry logic, not SNS's endpoint-specific retry mechanism.
- C
Set the SQS queue's visibility timeout to a value greater than the Lambda function's processing time
Why wrong: Setting the SQS queue's visibility timeout to a value greater than the Lambda function's processing time primarily prevents duplicate processing of a message by multiple consumers during a single processing attempt. While a longer timeout allows the Lambda function sufficient time to complete its work and can facilitate retries for transient failures (as the message reappears if not deleted), it does not inherently ensure reliability if a message consistently fails processing due to persistent errors or malformed data, which would still lead to message loss without a DLQ.
- D
Configure the SNS topic to use server-side encryption
Why wrong: Configuring the SNS topic to use server-side encryption (SSE) with AWS KMS protects the confidentiality of messages by encrypting them at rest within the SNS topic and during delivery to encrypted SQS queues. This is a crucial security measure for sensitive data, ensuring that unauthorized parties cannot access message content. However, encryption does not address the operational reliability of message delivery or the ability to recover messages that fail processing, which are distinct concerns from data security.