SysPadLessons › messaging lessons › SNS

How SNS works

Pub/sub messaging for fan-out to SQS, Lambda, HTTP, email, and SMS. Publishes are effectively unlimited; the ceiling is on deliveries, so the subscriber count divides it.

Where SQS is a line that one worker pulls from, SNS is a megaphone. A publisher shouts one message to a topic, and SNS instantly pushes a copy to every subscriber, queues, functions, webhooks, even SMS. One event, many independent reactions, and the publisher never needs to know who’s listening.

What you will learn

Publish/subscribe: one to many

SNS is pub/sub: publishers send messages to a topic; subscribers register interest in that topic. SNS pushes each message to all current subscribers, the opposite of SQS, where one consumer pulls a message that only it receives.

The fan-out pattern (SNS → SQS)

The most common production pattern subscribes several SQS queues to one SNS topic. Each service then drains its own queue at its own pace, with the queue’s durability, retries, and dead-letter safety net.

"Order placed" → one topic → queues for billing, inventory, and notifications, each processing independently.

Filtering: only the events you care about

A subscriber can attach a filter policy so it only receives messages whose attributes match (e.g. eventType = "refund"). SNS evaluates the filter and skips delivery to subscribers that don’t match.

That keeps one broad topic useful for many consumers without each one having to receive, then discard, everything.

Standard vs FIFO topics

Like SQS, SNS offers Standard topics (high throughput, best-effort ordering, possible duplicates) and FIFO topics (strict ordering and deduplication, paired with FIFO queues, lower throughput).

Flashcards

One-line difference between SNS and SQS delivery?
SNS pushes a copy to many subscribers (pub/sub); SQS holds a message for one consumer to pull (point-to-point).
Why is SNS → multiple SQS queues the go-to event-driven pattern?
Each service gets its own durable, retryable copy and processes independently, fan-out breadth from SNS plus per-consumer buffering from SQS.
A subscriber wants only a subset of a topic’s messages. How, without a new topic?
Attach a filter policy to the subscription; SNS only delivers messages whose attributes match.
Does the publisher need to know who its subscribers are?
No. Publishers send to the topic; subscribers come and go independently. That decoupling is the point of pub/sub.
When do you choose an SNS FIFO topic?
When fan-out must be strictly ordered and de-duplicated (paired with FIFO queues), accepting lower throughput than Standard.

Sources

Open the SysPad canvas · Official SNS documentation

Other messaging lessons