SQS standard vs FIFO queues, visibility timeout and DLQs
A standard queue gives nearly unlimited throughput with at-least-once delivery and best-effort ordering, so consumers must handle duplicates. A FIFO queue gives strict order within each message group and exactly-once processing, with lower throughput: 300 API calls per second per method, or 3,000 messages per second with batching.
Standard vs FIFO
Standard queues store copies of each message across multiple Availability Zones and can deliver a message more than once, so make processing idempotent. Order is best effort.
FIFO queues order messages within a message group ID; different groups can be processed in parallel. Every message needs a group ID. Duplicates are prevented with a MessageDeduplicationId or content-based deduplication, so a producer can safely retry a failed send with the same deduplication ID. High throughput mode raises the limit to 30,000 transactions per second with relaxed ordering across groups.
Visibility timeout
A received message stays in the queue but is hidden from other consumers for the visibility timeout. The default is 30 seconds. If the consumer does not delete it in time, it becomes visible again and another consumer can process it.
For jobs whose duration varies, AWS recommends a heartbeat that calls ChangeMessageVisibility to extend the timeout while work continues. The maximum is 12 hours from first receipt, and extending does not reset that limit. Setting the timeout to 0 releases a message at once.
Dead-letter queues and fan-out
A redrive policy on the source queue sets maxReceiveCount, the number of receives before a message moves to the dead-letter queue. The DLQ must be in the same account and Region. A redrive allow policy on the DLQ controls which source queues may use it; byQueue lists up to 10 source queue ARNs.
To fan out, subscribe several SQS queues to one SNS topic. SNS pushes a copy of each published message to every queue, and each consumer reads its own queue at its own pace.
Where the exam catches people
Believing a standard queue never delivers duplicates: delivery is at least once, so consumers must be idempotent.
Believing a long fixed visibility timeout is best for variable jobs: AWS recommends extending it with ChangeMessageVisibility as a heartbeat.
Believing the receive request attempt ID deduplicates sends: producers retry with the same message deduplication ID; the attempt ID is for consumer retries.
Believing maxReceiveCount is set on the dead-letter queue: it goes in the redrive policy on the source queue.
Believing a dead-letter queue can be in any Region: it must be in the same account and Region as the source queue.