← Back to Index
Chapter 11 of 20

SQS, SNS & Messaging

Domain 3 — High-Performing Architectures (24%)
📨
Question 1Knowledge

An SQS consumer retrieves a message and begins processing it. Before processing completes, the visibility timeout expires. What happens to the message?

Explanation

Visibility timeout (default 30 seconds, max 12 hours) hides a message from other consumers while it is being processed. If processing completes successfully, the consumer deletes the message. If the timeout expires before deletion, the message reappears and can be retried. Set the visibility timeout to slightly longer than your expected processing time.

Question 2Scenario

A financial application requires that messages are processed in the exact order they are sent, and each message must be processed exactly once with no duplicates. Which SQS queue type meets these requirements?

Explanation

FIFO queues guarantee strict message ordering and exactly-once processing (using deduplication IDs). They have a lower throughput limit: up to 3,000 messages/second with batching, or 300 without. Standard queues offer nearly unlimited throughput but only guarantee at-least-once delivery and best-effort ordering. FIFO queue names must end with ".fifo".

Question 3Scenario

When a new order is placed, a company needs to simultaneously: (1) send an email confirmation, (2) update inventory in an SQS queue, and (3) log the event to an SQS analytics queue. What is the MOST efficient architectural pattern?

Explanation

The SNS Fan-out pattern decouples the publisher from subscribers. A single SNS publish triggers all subscribers simultaneously. SQS queues subscribing to SNS provide durable buffers for downstream processors. This avoids tight coupling, ensures all subscribers receive the message, and scales independently.

Question 4Scenario

Messages in an SQS queue are failing processing after 3 retries. The team wants to isolate these failed messages for debugging without losing them. Which feature should they configure?

Explanation

A Dead Letter Queue is a separate SQS queue configured as the DLQ for a source queue. When a message's ReceiveCount exceeds the maxReceiveCount threshold (configurable), SQS moves it to the DLQ automatically. You can then inspect DLQ messages to debug failures. DLQs can also be configured for SNS subscriptions.

Question 5Knowledge

What is the maximum message retention period for an SQS queue?

Explanation

SQS message retention is configurable from 60 seconds (minimum) to 14 days (maximum). The default is 4 days. Messages not consumed within the retention period are automatically deleted by SQS. For longer-term storage, messages should be persisted to S3, DynamoDB, or another durable store before deletion.