Notification Design with Amazon SNS - Topic and Subscription Patterns
Learn how to choose between Standard and FIFO topics, implement the SQS fan-out pattern, and use subscription filters for conditional routing.
Topic Design and Subscriptions
SNS topics come in two types: Standard and FIFO. Standard topics provide virtually unlimited throughput with best-effort message ordering. FIFO topics provide strict ordering per message group ID and deduplication via message deduplication IDs. FIFO topic subscribers are limited to SQS FIFO queues. Subscription protocols support SQS, Lambda, HTTP/HTTPS, email, SMS, and Kinesis Data Firehose. By attaching message attributes, you can enable conditional routing through subscription filter policies.
Delivery Reliability and Fan-Out
The SNS + SQS fan-out pattern subscribes multiple SQS queues to an SNS topic, delivering messages to all queues with a single publish. Each queue's consumer processes independently, so a failure in one consumer does not affect others. Retry policies for delivery failures vary by protocol; HTTP/HTTPS endpoints use exponential backoff for retries. Messages that cannot be delivered after retries are sent to a dead-letter queue (SQS queue) for later investigation or reprocessing. Enabling message archiving stores past messages and allows redelivery to new subscribers.
FIFO Topics and Message Attributes
FIFO topics provide message ordering guarantees and deduplication, achieving strict ordered processing when combined with FIFO SQS queues. Message group IDs logically group messages, guaranteeing order within each group. Message attributes attach metadata (event type, priority, source), and subscription filter policies implement attribute-based routing. Message data protection automatically detects PII (personally identifiable information) and lets you configure policies for masking or rejection. To gain a deeper understanding of notification design integration patterns, specialized books (Amazon) can be helpful.
SNS Pricing
Publishing to SNS Standard topics costs approximately $0.50 per million requests. FIFO topics cost approximately $0.30 per million requests. Delivery to HTTP/S endpoints costs approximately $0.60 per million notifications, while delivery to SQS is free. SMS delivery uses per-message pricing that varies by destination country. Message filtering is available at no additional charge, reducing unnecessary message delivery and optimizing downstream costs.
Summary
SNS is a topic-based Pub/Sub messaging service that provides flexible message routing through fan-out patterns and subscription filters. FIFO topics deliver ordering guarantees and deduplication, while message data protection enables automatic PII detection and masking. Combined with SQS, it builds reliable asynchronous processing pipelines, with DLQs ensuring delivery failures are reliably captured.