intermediate
SNS
Fan out notifications to queues, functions, HTTP endpoints, or email subscribers using topic-based publish-subscribe semantics.
SNS is a managed pub/sub service that fans out messages to SQS queues, Lambda functions, HTTP/S endpoints, email, and SMS. Publishers send to a topic; subscribers receive independent copies filtered by subscription policy.
Typical Node.js flow: domain event published to SNS, multiple SQS queues subscribed for billing, analytics, and notifications — each consumer scales independently. Message attributes enable routing filters without separate topics per consumer.
| vs SQS | SNS | |--------|-----| | Delivery model | One-to-many broadcast | | Persistence | Push to subscribers; pair with SQS for buffering | | Ordering | FIFO topics available for strict sequences |
Encrypt topics with KMS when payloads are sensitive. Confirm HTTP subscriptions to prevent open webhook endpoints.
On interviews: SNS plus SQS fan-out pattern, filter policies, retry behavior on HTTP subscriptions, and when EventBridge replaces SNS for event routing.
Common pitfalls: subscribing Lambda directly without DLQ on async invokes; unconfirmed HTTP endpoints; one giant topic without filters causing unnecessary invocations.
The trade-off is simple broadcast semantics versus less durable delivery unless you buffer with SQS downstream.
Checklist:
- Fan out to SQS for reliable, replayable consumers.
- Use filter policies to limit noise and cost.
- Secure topics with KMS and least-privilege publish roles.
- Monitor failed deliveries and DLQs on subscribed queues.