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 deliver messages in best-effort order, and the messages-per-second publish quota applies per account and per Region (you can request an increase). FIFO topics provide strict ordering per message group ID and deduplication via message deduplication IDs. FIFO topics can deliver to both SQS standard and FIFO queues, but not to customer managed endpoints such as email, SMS, or HTTP/S. Subscription protocols support SQS, Lambda, HTTP/HTTPS, email, SMS, and Amazon Data Firehose (formerly Kinesis Data Firehose). By attaching message attributes, you can enable conditional routing through subscription filter policies.
Fan-Out Pattern Design
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 if one consumer stops, the other queues can continue processing. One example of this pattern is an order processing system, where a single order event is simultaneously delivered to an inventory update queue, email notification queue, and analytics recording queue. The Standard topic subscription quota is 12,500,000 per topic, and new processing can be added by adding a subscription without changing the publisher. For cross-account fan-out, the topic policy allows Subscribe from SQS queues in other accounts, keeping microservices loosely coupled.
Subscription Filters and Delivery Guarantees
Subscription filter policies come in two types: attribute-based and payload-based. Attribute-based filters define conditions on message attributes (exact string match, prefix match, numeric comparison, exists check). Payload-based filters execute filtering against JSON paths in the message body, supporting nested fields. Filters are evaluated on the SNS side, so messages that don't match conditions are never delivered to subscribers, reducing downstream processing costs and noise. Retry policies for delivery failures vary by endpoint type; AWS managed endpoints such as SQS are retried over 23 days, while HTTP/S has a cap on total retry time. Messages that cannot be delivered after retries are sent to a dead-letter queue (DLQ) for later investigation or reprocessing. The DLQ redrive feature allows redelivering messages to the original subscription after the issue is resolved.
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, but new customers cannot use this feature from April 30, 2026 (existing customers can continue to use it).
Design Pitfalls and Operational Considerations
The maximum SNS message size is 256 KB; for larger payloads, store the content in S3 and send only a pointer via SNS using the Extended Client Library pattern. FIFO topic throughput is limited to 300 messages per second per message group, so high-throughput designs distribute message group IDs. As filter policy complexity grows, debugging becomes difficult - limit the number of attributes in filter conditions, and consider EventBridge for complex routing. HTTP/HTTPS endpoint subscriptions will not receive messages until subscription confirmation is complete, so implement confirmation token handling in the endpoint. Enabling message encryption (SSE) requires the subscriber's IAM role to have KMS decrypt permissions, which is often overlooked.
SNS vs. EventBridge - When to Use Which
Both SNS and EventBridge are core to event-driven architectures, but they have different strengths. SNS suits simple fan-out and delivery to diverse protocols (SQS, Lambda, HTTP, SMS, email). EventBridge offers rule pattern matching against event structure, a schema registry, and SaaS integrations. As a practical guideline, use SNS for in-application fan-out (order → multiple queues) and EventBridge for inter-service event routing (complex conditional branching, external SaaS events). The SNS Standard topic subscription quota is 12,500,000 per topic, while EventBridge has a limit on targets per rule and scales through the number of rules.
SNS Pricing
SNS pricing depends on the topic type, and Standard topics are billed by the number of API requests such as publishes. FIFO topics are billed by the number of published and subscribed messages and their respective payload data. Delivery to HTTP/S endpoints is billed by the number of notifications, while delivery to SQS has no charge (standard SQS pricing applies). SMS delivery uses per-message pricing that varies by destination country. Attribute-based message filtering is free, while payload-based filtering is billed by the amount of payload data scanned.
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. Combined with SQS, it builds reliable asynchronous processing pipelines, with DLQs capturing messages that fail delivery.
References (Official AWS Resources)
The primary sources for this page are the official AWS website and documentation. Check the official pages below for the latest specifications and pricing.
- Amazon SNS official page
- Amazon SQS official page
- AWS Lambda official page
- AWS Documentation (official)
If this page and the official documentation disagree, treat the official documentation as authoritative.