TECH_COMPARISON
Amazon SNS vs SQS: A Detailed Comparison for System Design
Compare Amazon SNS and SQS on pub/sub vs point-to-point messaging, delivery guarantees, and fan-out patterns in AWS architectures.
Amazon SNS vs SQS
Amazon SNS and SQS solve different messaging problems and are most powerful when used together. SNS is a pub/sub notification service for fan-out. SQS is a message queue for point-to-point task distribution.
When to Use Each Alone
Use SNS alone when you need to notify multiple subscribers about an event — sending alerts to email, triggering Lambda functions, or pushing to mobile devices. SNS pushes messages to subscribers and does not store them.
Use SQS alone when you need a reliable task queue — job processing, work distribution, or buffering between a fast producer and slow consumer. SQS stores messages until a consumer processes them.
The Fan-Out Pattern: SNS + SQS
The most important AWS messaging pattern combines SNS and SQS. An SNS topic fans out events to multiple SQS queues. Each queue serves a different consumer with independent processing, retry, and dead letter handling.
Example: An order is placed. SNS publishes the OrderCreated event. Three SQS queues receive copies:
- Payment processing queue
- Inventory update queue
- Notification queue
Each consumer processes independently. If payment processing fails, it retries without affecting inventory or notifications.
FIFO Mode
Both SNS and SQS support FIFO mode for ordered, exactly-once messaging. SNS FIFO topics can only deliver to SQS FIFO queues — not to Lambda or HTTP endpoints. This constraint matters for architecture design.
Filtering Reduces Cost
SNS subscription filter policies let each subscriber receive only relevant messages. Without filtering, every subscriber processes every message and discards irrelevant ones — wasting compute. Filtering is essential for high-volume event-driven architectures.
For a deeper dive into these patterns, see our system design interview guide and AWS architecture concepts.
GO DEEPER
Master this topic in our 12-week cohort
Our Advanced System Design cohort covers this and 11 other deep-dive topics with live sessions, assignments, and expert feedback.