Amazon SNS
One message in, many copies out: a megaphone for systems.
Amazon SNS (Simple Notification Service) is a publish/subscribe service. You create a topic, several subscribers sign up to it, and every message published to the topic is delivered to all of them at once. A subscriber can be an AWS Lambda function, an Amazon SQS queue, an HTTPS endpoint, an email address or a phone number (SMS).
The difference with a queue: Amazon SQS hands each message to one consumer; a topic copies each message to every subscriber. The two are often combined: SNS fans an event out to several SQS queues, each owned by a different team, and each team processes it at its own pace.
Example: when an order is paid, the shop publishes 'order 4521 paid' to a topic. The warehouse queue receives it, the invoicing function receives it, the analytics pipeline receives it, and the customer gets an SMS. The checkout code published once and has no idea who is listening.
SNS is also how Amazon CloudWatch alarms reach people: the alarm publishes to a topic, and the topic emails or texts whoever is on call.
Keep in mind
- Publish once, deliver to every subscriber at the same time (fan-out).
- Subscribers can be code (Lambda, SQS, HTTPS) or people (email, SMS, push notifications).
- SNS does not keep messages for later: if nobody is subscribed when you publish, the message is gone.
- Filters let each subscriber receive only the messages it cares about.