CloudGuild · Blog · Cheat sheets · Lessons · Certifications
Amazon SQS & SNS — Messaging and Notification Services: When to Use What (And How the Exam Tests It)
Learn when to use Amazon SQS and SNS for messaging and notifications, plus how to tackle related questions on the SAA-C03 exam.
In the world of cloud architecture, choosing the right messaging service is crucial. Amazon SQS and SNS serve different purposes, and understanding when to use each can impact your application’s performance and reliability.
When to Choose Amazon SQS
We opt for Amazon SQS when decoupling application components is necessary. This service excels in buffering workloads and ensuring message delivery with at-least-once guarantees. Use SQS when:
- You need to decouple microservices and distributed systems.
- You require reliable message delivery, even under high load.
- Your application design allows for out-of-order message processing.
SQS Options: Standard vs. FIFO
| Feature | SQS Standard Queue | SQS FIFO Queue |
|---|---|---|
| Delivery Guarantee | At-least-once delivery | Exactly-once processing |
| Order | Unordered | Ordered |
| Throughput | Unlimited | Limited to 300 transactions per second |
| Cost | Generally lower | Higher due to ordering guarantees |
When to Choose Amazon SNS
Amazon SNS is ideal for scenarios where you need to push notifications to multiple endpoints. It supports fan-out messaging patterns, making it suitable when:
- You need to send messages to various subscribers (e.g., Lambda, HTTP, email).
- Your application design requires immediate notification without waiting for processing.
SNS Features
- Supports multiple protocols for delivery.
- Allows for immediate message distribution to subscribers.
- Can integrate with SQS for further processing if needed.
Key Architectural Decisions
Choosing between SQS and SNS involves considering key architectural decisions:
- Message Retention in SQS: Set a retention period from 1 minute to 14 days. Balance costs with your data availability needs.
- SNS Topic Subscriptions: Plan these carefully to optimize message delivery. Consider the number of subscribers and the protocol used.
Gotchas & Exam Traps
Be aware of common pitfalls that can trip you up on the exam:
- Message Size Limit: SQS has a 256 KB limit per message. Ensure your payloads fit within this restriction.
- SNS and FIFO: SNS does not support message filtering for SQS FIFO subscriptions. This is critical for design considerations.
- Visibility Timeout in SQS: Understand how visibility timeout impacts message processing. A short timeout can lead to duplicate processing.
How the Exam Tests This
The SAA-C03 exam assesses your knowledge of SQS and SNS through specific patterns:
- Scenario-based questions: You may be presented with a situation requiring you to choose between SQS and SNS based on architectural needs.
- Cost optimization: Questions may involve selecting the correct retention period or subscription strategy to manage costs effectively.
- Implementation specifics: Expect questions about message limits, visibility timeout, and subscription configurations that can affect application behavior.
The Rule to Remember
Choose SQS for decoupling and reliable message delivery, and SNS for immediate notifications to multiple endpoints.
For further practice, Take the free SAA-C03 mock exam.