TECH_COMPARISON
SQS vs SNS: A Detailed Comparison for System Design
Compare Amazon SQS and SNS on messaging patterns, delivery models, and when to use queues vs pub/sub in AWS architectures.
SQS vs SNS
Amazon SQS and Amazon SNS are complementary AWS messaging services often confused with each other. SQS is a message queue (point-to-point). SNS is a notification service (pub/sub fan-out). Understanding the difference is essential for system design interviews.
Core Difference: Queue vs Topic
SQS is a queue. A producer sends a message, and exactly one consumer receives it. Messages are stored until consumed. This is the classic producer-consumer pattern for task distribution.
SNS is a topic. A producer publishes a message, and all subscribers receive a copy. There is no storage — if a subscriber is unavailable, the message may be lost (unless the subscriber is an SQS queue).
The SNS + SQS Fan-Out Pattern
The most powerful AWS messaging pattern combines both: SNS topic fans out to multiple SQS queues. Each queue buffers messages for its consumer independently. This gives you:
- Fan-out (one event, many consumers) from SNS
- Persistence and retry from SQS
- Independent consumption rates per consumer
For example, when an order is placed, SNS publishes the event. SQS queues for payment processing, inventory, and notifications each receive a copy and process independently.
Message Filtering
SNS supports subscription filter policies — subscribers only receive messages matching their filter criteria. This avoids sending irrelevant messages to consumers. SQS has no built-in filtering; consumers receive everything in the queue.
FIFO Support
Both SQS and SNS support FIFO (First-In, First-Out) with ordering per message group ID and exactly-once processing. SNS FIFO topics can only deliver to SQS FIFO queues.
Decision Framework
Use SQS alone for simple task queues. Use SNS alone for fire-and-forget notifications. Use SNS + SQS together for durable fan-out patterns. This is one of the most commonly tested AWS architecture patterns in interviews. See our pricing page for cost comparisons.
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.