
- Decouple producers and consumers so services can evolve independently.
- Fan-out notifications to many endpoints (SQS, Lambda, HTTP, mobile push, SMS, email).
- Offload reliability, retry logic, and scaling to a managed AWS service.
- A topic is a logical channel grouping related messages (for example, a
new-usertopic). - Publishers send messages to a topic; SNS delivers each message to every subscriber of that topic.
- Topics represent events or categories of events so multiple consumers can respond independently.
- Subscribers register to a topic to receive messages.
- Supported endpoint types include Amazon SQS, AWS Lambda functions, HTTP/HTTPS endpoints, email, SMS, and mobile push.
- Each subscriber processes messages according to its own logic (queues, functions, services).
- Publishers are producers of messages: applications, Lambda functions, EC2 instances, containers, or other services.
- Use the SNS API/SDK (e.g.,
Publish,PublishBatch) to send messages. - Messages can be plain text or structured JSON, depending on subscribers’ expectations.
- Payloads that carry notifications, alerts, or event data.
- SNS supports single-message publishing (
Publish) and batching (PublishBatch, up to 10 messages per request).

Standard topics
- High throughput, designed for scale.
- Messages can arrive out of order and may be delivered more than once; make subscribers idempotent.
- Use when ordering and exact-once delivery are not required.

- Guarantees first-in, first-out delivery and deduplication.
- Requires publishers to provide a
messageGroupIdto maintain ordering within a group. - Use for workloads that require strict ordering and no duplicates (e.g., banking, inventory).
- Note throughput limits: up to 300 transactions/sec or up to 10 MB/sec per FIFO topic.
Exam tip: Use standard topics for maximum throughput when duplicates and out-of-order delivery are acceptable. Use FIFO topics for strict ordering and deduplication, but be aware of the lower throughput limits (300 messages/sec or 10 MB/sec).

- Batch publishing: Use
PublishBatchto send up to 10 messages per API request to reduce API overhead and costs. - Message size: Max payload size is 256 KB per message.
- For larger payloads: store the data in Amazon S3 and publish a message containing a reference (object key or presigned URL). Subscribers retrieve the full payload from S3.
- Design subscriber logic to be idempotent when using standard topics, or use FIFO topics for deduplication and ordering where required.

- Secure notifications: Server-side encryption with AWS KMS, resource policies for access control, and AWS PrivateLink support.
- Fan-out architectures: Distribute a single event to multiple consumers (SQS queues, Lambda, HTTP endpoints, mobile push, email) for scalable event-driven systems.
- Mobile & endpoint notifications: Push to mobile devices, SMS, and email channels.
- Integration: Many AWS services can publish events to SNS topics, enabling broad event distribution across systems.

- When to use SNS: decoupling, broadcasting/fan-out, mobile push, and simple notification workflows.
- When to use SQS instead: point-to-point queueing with long-lived retention, visibility timeouts, and worker-based processing.
- For complex workflows: combine SNS (fan-out) with SQS queues or Lambda subscribers to build reliable, scalable pipelines.
- AWS SNS documentation: https://docs.aws.amazon.com/sns/
- Learn more about using SNS with Lambda: https://learn.kodekloud.com/user/courses/aws-lambda
- Amazon SNS is a managed pub/sub service that simplifies real-time notification delivery across multiple consumers.
- Choose standard topics for maximum throughput; design subscribers to handle duplicates and potential out-of-order delivery.
- Choose FIFO topics when strict ordering and deduplication are required, and keep throughput limits in mind.
- Optimize with batching, S3 references for large payloads, and secure communications using KMS and resource policies.