Amazon SNS
A fully managed Pub/Sub messaging service that delivers a single message to multiple subscribers simultaneously, enabling the fan-out pattern
Overview
Amazon SNS (Simple Notification Service) is a fully managed messaging service based on the publish/subscribe (Pub/Sub) model. When a publisher sends a message to a topic, it is simultaneously delivered to all endpoints subscribed to that topic (Lambda, SQS, HTTP/S, email, SMS, and mobile push). A single topic supports up to 12.5 million subscriptions, and you can create up to 100,000 topics per account. Standard topics provide virtually unlimited throughput per second, while FIFO topics offer ordering guarantees and deduplication.
The Fan-Out Pattern - One-to-Many Delivery
The fan-out pattern is SNS's most powerful capability. When a single event (such as an order confirmation) is published to an SNS topic, it is simultaneously delivered to multiple subscribers such as the inventory management system, payment system, notification system, and analytics system. Each subscriber processes the event independently, so a failure in one system does not affect the others. The SNS + SQS fan-out pattern is particularly powerful. You subscribe multiple SQS queues to an SNS topic and place a consumer behind each queue. SNS delivers the message to every queue, and each consumer processes it at its own pace. If one consumer falls behind, the others are unaffected.
Message Filtering and Pricing
SNS message filtering policies let you narrow down which messages each subscriber receives. You define filtering rules based on message attributes, and only messages matching the conditions are delivered to the subscriber. Without filtering, every subscriber receives every message and must discard irrelevant ones at the application level. SNS pricing is based on API request count and data transfer volume. The first 1 million requests per month are free, and subsequent requests cost $0.50 per million. Message delivery to SQS and Lambda is free, but delivery to SMS and mobile push incurs additional charges. The Azure equivalents are Azure Service Bus topics and Azure Event Grid, which provide similar Pub/Sub patterns.
Practical Use Cases
SNS is most widely used as a notification target for CloudWatch alarms. When CPU utilization exceeds a threshold or error rates spike, notifications are sent via an SNS topic to email or Slack (through Lambda). Combined with EventBridge, you can receive real-time notifications for AWS service events such as EC2 instance state changes and CodePipeline deployment results. For mobile applications, SNS's mobile push notification feature can send push notifications to both iOS (APNs) and Android (FCM). For a systematic study of SNS from basics to advanced topics, books on Amazon are a great resource.