System Design Playbook
19 · Async & cloud8 min read

AWS SQS vs SNS: queues vs pub/sub

Two AWS messaging services that sound alike and solve different problems. SQS is a queue: messages wait until one worker processes them. SNS is a topic: every message is pushed to all subscribers at once. And the fan-out pattern that combines both.

In one sentence

SQS stores messages until one consumer pulls and processes each of them; SNS pushes each message to every subscriber immediately and doesn't store it.

See the difference

Switch between the three patterns. In SQS, make a worker fail and watch messages get retried and finally land in the dead-letter queue. In fan-out, notice how the slow analytics worker only backs up its own queue.

SQS (queue) vs SNS (topic)
Pattern
ProducerordersQueueWorker 1pollingWorker 2polling
Messages sent
0
Waiting in queues
0
Deliveries
0
In DLQ
0
SQS stores messages until a worker pulls them. Each message is processed by one worker; if it fails, the message becomes visible again and is retried, and after a few attempts it goes to a dead-letter queue.

SQS: a queue (point-to-point)

  • Producers send messages; they stay in the queue (up to 14 days) until a consumer receives them.
  • Consumers poll (ideally with long polling) and process at their own pace.
  • While a message is being processed it's hidden (visibility timeout). If the consumer doesn't delete it in time, it becomes visible again and is retried.
  • After N failed attempts it moves to a dead-letter queue (DLQ) for inspection.
  • Standard queues: nearly unlimited throughput, at-least-once delivery, best-effort order. FIFO queues: strict order and exactly-once processing, with lower throughput.

Use it to decouple a fast producer from slower work: order processing, sending emails, resizing images, writing to a database at a safe pace.

SNS: a topic (publish / subscribe)

  • A publisher sends one message to a topic.
  • SNS pushes a copy to every subscriber: SQS queues, Lambda functions, HTTP endpoints, email, SMS, mobile push.
  • It doesn't keep messages for later: if an HTTP subscriber is down, SNS retries for a while and then gives up (or sends to a DLQ if you configured one).
  • Filter policies let each subscriber receive only the messages it cares about (for example type = "refund").

Use it when one event must trigger many independent reactions: "order placed" → charge the card, email the customer, update analytics, notify the warehouse.

Side by side

SQSSNS
ModelQueue (point-to-point)Topic (pub/sub)
DeliveryConsumers pullSNS pushes
Who gets a messageOne consumerEvery subscriber
StorageKeeps messages until processedNo storage, deliver now
RetriesVisibility timeout + DLQDelivery retries per protocol
Typical useBackground jobs, buffering, smoothing loadNotifications, broadcasting events

Fan-out: SNS + SQS together

The most common production pattern: publish an event to an SNS topic and subscribe one SQS queue per service. Each service gets its own durable copy, processes it at its own pace, retries on its own, and a slow or broken consumer doesn't affect the others.

Key takeaways

  • 01SQS = queue: messages wait, one consumer processes each, failures are retried and end in a DLQ.
  • 02SNS = topic: each message is pushed to all subscribers at once, nothing is stored.
  • 03Fan-out (SNS → several SQS queues) gives each service its own durable copy of every event.
  • 04Consumers must be idempotent: with at-least-once delivery the same message can arrive twice.

Check your understanding

1 of 3

What's the key difference between SQS and SNS?

Related concepts