Amazon SNS
Pub/sub messaging and mobile push notification service
SNS is like a radio station that broadcasts messages to multiple listeners simultaneously. Instead of sending the same message to 10 different systems individually, you publish it once to an SNS topic, and all subscribers receive it automatically. Subscribers can be email addresses, phone numbers (SMS), Lambda functions, SQS queues, or HTTP endpoints. It's perfect for fan-out scenarios: one event triggers multiple actions. Think of it as a megaphone that announces news to everyone who's interested, whether they're listening via email, text, or application.
SNS uses a pub/sub model: publishers send messages to topics, and subscribers receive messages from topics. Topics support multiple subscription types: email, SMS, HTTP/HTTPS, Lambda, SQS, mobile push (iOS, Android), and Amazon Data Firehose.
Key Capabilities
- Topics receive a single published message and fan it out simultaneously to all subscribed endpoints in parallel
- Subscription protocols include SQS, Lambda, HTTP/HTTPS, email, SMS, mobile push (APNs, FCM), and Amazon Data Firehose
- Message filtering lets each subscriber define a filter policy so it only receives messages matching specific attributes, reducing unnecessary processing
- FIFO topics deliver in strict order with deduplication to SQS FIFO queues; SQS standard queues can also subscribe, without ordering, and email, SMS, mobile, and HTTP endpoints cannot
- Dead-letter queues capture messages that fail delivery to a subscriber after retries, preventing silent message loss
- Supports message encryption via KMS, cross-account publishing and subscribing, and message archiving with replay for reprocessing past events
Gotchas & Constraints
Gotcha #1: SNS delivers messages at-least-once; subscribers must handle duplicates. Gotcha #2: SMS costs vary by country and can be expensive; use SNS budgets to control costs. Constraints: Maximum 256KB message size, maximum 12.5 million subscriptions per topic, and FIFO topics limited by default to 3,000 messages per second or 20 MB per second per topic, whichever comes first; high throughput mode (FifoThroughputScope set to MessageGroup, which cannot be reverted) raises that per-topic limit, leaving each message group capped at 300 per second, and AWS recommends choosing the scope when you create the topic.
Illustrative scenario; figures are examples, not verified customer results.
A monitoring system detects a critical production issue: database CPU at 95%. They need to alert the on-call engineer (SMS), post to Slack (HTTP webhook), create a ticket in Jira (Lambda function), and log to S3 (SQS queue to Lambda). Instead of implementing each notification separately, they publish one message to an SNS topic with four subscriptions: SMS to on-call phone, HTTPS to Slack webhook, Lambda function to create Jira ticket, and SQS queue for S3 logging. When the alert fires, all four actions happen simultaneously. They use message filtering: only 'critical' severity alerts trigger SMS (to avoid alert fatigue), but all alerts go to Slack and Jira. During a major outage, 100 alerts fire in 5 minutes; SNS delivers all notifications reliably, and the team responds immediately. They later add a fifth subscription (email to management) without changing the alerting code.
The Result
flexible notification system, easy to extend, and reliable delivery.