CloudGuild · Blog · Cheat sheets · Lessons · Certifications
Amazon SQS & SNS — Messaging and Notification Services
Amazon SQS (Simple Queue Service) and SNS (Simple Notification Service) provide managed messaging and notification capabilities for building resilient applications.
What it is
- Amazon SQS: Fully managed message queuing service that enables decoupling of microservices and distributed systems.
- Amazon SNS: Fully managed pub/sub messaging service for sending notifications to multiple subscribers.
When I reach for it
- Use SQS when you need to decouple application components, buffer workloads, or ensure message delivery with at-least-once delivery.
- Use SNS when you need to push notifications to multiple endpoints (e.g., Lambda, HTTP, email) or perform fan-out messaging patterns.
Key architectural decisions
- Choose between SQS standard (at-least-once delivery, unordered) and FIFO (exactly-once processing, ordered) queues based on application needs.
- Decide on the message retention period (from 1 minute to 14 days) in SQS to balance cost and data availability.
- Plan SNS topic subscriptions carefully to optimize message delivery and reduce costs.
Gotchas & exam traps
- SQS has a limit of 256 KB per message; ensure message size is managed accordingly.
- SNS does not support message filtering for SQS FIFO subscriptions; be aware of this when designing.
- Understand the implications of message visibility timeout in SQS to avoid message processing issues.
The architect view
- SQS and SNS together enable a highly scalable and decoupled architecture, enhancing application resilience.
- Monitor and optimize costs by understanding message throughput and retention settings.