Master SQS Standard vs FIFO queues, visibility timeout, dead letter queues, and the SNS fan-out pattern for decoupled architectures.
SQS and SNS — Decoupled Messaging
SQS and SNS are messaging services that decouple your application components — producers and consumers can operate independently without being directly connected.
Teacher Note: Think of a restaurant kitchen. The waiter (producer) puts order tickets on a clip (SQS queue). The chef (consumer) picks up tickets at their own pace. If the kitchen gets slammed, tickets stack up safely — the waiter never has to wait for the chef. This is decoupling.
SQS — Simple Queue Service
| Feature | Standard Queue | FIFO Queue |
|---|
| Ordering | Best-effort (may be out of order) | STRICT ordering guaranteed |
| Delivery | At least once (possible duplicates) | Exactly once (no duplicates) |
| Throughput | Unlimited | 3,000 messages/second with batching |
| Best For | High-volume, order-independent tasks | Financial transactions, inventory updates |
Key SQS Concepts
- Visibility Timeout: how long a message is invisible after being received — gives consumer time to process (default 30 seconds)
- Dead Letter Queue (DLQ): receives messages that fail processing N times — for debugging and alerts
- Long Polling: consumer waits up to 20 seconds for messages — cheaper than short polling
- Message Retention: 1 minute to 14 days (default 4 days)
SNS — Simple Notification Service
SNS publishes one message to MANY subscribers simultaneously (fan-out pattern). One event can trigger email alerts, SQS queues, Lambda functions, and mobile push notifications at the same time.
ORDER PLACED event --> SNS Topic
|
|---> SQS Queue --> Lambda: Update inventory
|---> SQS Queue --> Lambda: Send confirmation email
|---> SQS Queue --> Lambda: Update recommendation engine
|---> Email: Alert business team
|---> Lambda: Update real-time dashboard
Exam Tip: The SNS + SQS fan-out pattern is one of the most tested SAA-C03 patterns. Publish to ONE SNS topic, fan out to MULTIPLE SQS queues — each queue is processed independently. This ensures: no message loss, independent scaling, and retry on failure. NEVER write to multiple SQS queues directly from the application.