Volume 10 · Chapter 7 — Messaging and Event-Driven Architecture
SQS Deep Dive: FIFO, Delivery, and Patterns
7.1 Introduction
The queues chapter covered visibility timeouts and dead-letter queues; the exam expects the deeper SQS details - standard vs FIFO queues (throughput, ordering, deduplication, message groups), polling modes, delay queues, large-message handling, and redrive. This chapter provides that depth.
7.2 Standard vs FIFO Queues
SQS has two queue types with a tested trade-off.Standard queuesoffer nearly unlimited throughput, at-least-once delivery (occasional duplicates), and best-effort ordering (not guaranteed).FIFO queuesguaranteeexactly-once processing(via deduplication) andstrict ordering, but with limited throughput (300 messages/second, or 3,000 with batching, higher with high-throughput mode). FIFO uses two concepts: amessage group ID(messages in the same group are ordered and processed one at a time; different groups process in parallel) and adeduplication ID(duplicates with the same ID within a 5-minute window are discarded, giving exactly-once). The exam pattern: standard for maximum throughput where order doesn’t matter and idempotent consumers handle duplicates; FIFO when strict ordering and exactly-once are required (e.g. ordered financial operations per account, using account ID as the message group).
flowchart TD
Q{Ordering / exactly-once needed?} -->|No, max throughput| Std[Standard queue - at-least-once, best-effort order]
Q -->|Yes, strict order + dedup| FIFO[FIFO queue - exactly-once, ordered]
FIFO --> MG[Message group ID - per-group ordering, parallel across groups]
FIFO --> DD[Dedup ID - discard duplicates in 5-min window] 7.3 Polling, Delay Queues, and Large Messages
Consumers retrieve messages by polling, andlong polling(wait up to 20s for a message) is preferred overshort pollingbecause it reduces empty responses, cost, and latency. Adelay queuepostpones delivery of new messages for a set time (up to 15 minutes), and per-messagetimersdelay individual messages. The maximum message size is 256 KB; for larger payloads, theSQS Extended Clientstores the body in S3 and passes a reference (or you store in S3 and enqueue a pointer). These are common exam details: use long polling to cut cost/empty receives, delay queues to defer processing, and S3-backed large messages beyond 256 KB.
7.4 Dead-Letter Queues, Redrive, and Scaling
Adead-letter queue (DLQ)captures messages that fail after a configured maximum receive count - isolating “poison” messages so they don’t block the queue and giving you a place to inspect them. TheDLQ redrivefeature moves messages back from the DLQ to the source queue for reprocessing after you fix the cause. Consumers scale with thecompeting-consumerspattern, usingqueue depth(ApproximateNumberOfMessages) as the scaling signal for the worker fleet (via Auto Scaling or Lambda event source mapping with batching). The exam expects DLQ + redrive for failure handling and queue-depth-driven scaling of consumers.
7.5 Banking Production Scenario
A bank uses a FIFO queue for per-account transaction ordering - the account ID is the message group ID so each account’s operations are strictly ordered and processed exactly once, while different accounts process in parallel. High-volume, order-insensitive notification work uses standard queues with idempotent consumers. Long polling minimizes cost and empty receives, a delay queue defers a retry-after-cooldown workflow, and payloads over 256 KB use the S3-backed extended client. Poison messages land in a DLQ for investigation and are redriven after a fix. Worker fleets scale on queue depth. This precise SQS design is exactly the professional-level messaging competence the certification targets.
7.6 Chapter Revision Notes
- Standard queue: near-unlimited throughput, at-least-once (duplicates), best-effort order; FIFO: exactly-once + strict order, limited throughput.
- FIFO uses message group ID (per-group ordering, parallel across groups) and dedup ID (exactly-once within a 5-min window).
- Long polling (up to 20s) beats short polling (fewer empty receives, lower cost); delay queues defer new messages up to 15 min; >256 KB uses the S3-backed extended client.
- DLQ captures messages exceeding max receive count; redrive returns them to the source after a fix.
- Scale consumers with competing consumers using queue depth as the signal (Auto Scaling or Lambda event source mapping).