Skip to main content
In this lesson we’ll cover Amazon Simple Notification Service (SNS) — a managed, highly available pub/sub service from AWS that routes messages from publishers to multiple subscribers. SNS eliminates the complexity of building real-time messaging infrastructure so distributed components (microservices, back-end processes, mobile clients) can stay synchronized reliably and at scale.
A slide diagram titled "Why Do We Need SNS?" showing AWS services (Lambda, EC2, EKS) publishing to Amazon Simple Notification Service, which then delivers messages to devices (mobile, laptop) and email. The slide notes SNS is efficient, reliable, and scalable.
Why use SNS?
  • 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.
Core concepts Topics
  • A topic is a logical channel grouping related messages (for example, a new-user topic).
  • 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
  • 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
  • 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.
Messages
  • Payloads that carry notifications, alerts, or event data.
  • SNS supports single-message publishing (Publish) and batching (PublishBatch, up to 10 messages per request).
A diagram of AWS SNS components showing publishers (Lambda, Amazon EC2, Amazon EKS) sending messages to an SNS Topic. Subscribers shown include Amazon SQS, a Lambda function, and mobile/desktop endpoints.
Topic types: Standard vs FIFO SNS supports two topic types with different guarantees. Choose the right type based on ordering, deduplication, and throughput requirements. 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.
A slide illustrating an "SNS – Standard Topic" with a cylindrical topic containing numbered messages, connected to application/subscriber icons (mobile, laptop, Lambda). A right-side panel lists advantages like "Best-effort ordering" and "Maximum throughput."
FIFO topics
  • Guarantees first-in, first-out delivery and deduplication.
  • Requires publishers to provide a messageGroupId to 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).
A diagram titled "SNS – FIFO Topic" showing a FIFO message queue with numbered messages in order and an Application/Subscriber box with mobile, laptop, and Lambda icons. A side panel lists advantages like strict ordering and a throughput limit of 300 messages/sec or 10 MB/sec.
Practical limits and tips
  • Batch publishing: Use PublishBatch to 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.
Limits and helpful numbers
A presentation slide titled "SNS – Tips and Tricks" with three rounded colored panels across the center. From left to right they read "1–10 messages per API request" (user/chat icon), "Batch to save cost" (conveyor/robot icon), and "256 KB data / 2 GB S3 link" (resize/expand icon).
Use cases and features
  • 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.
A presentation slide titled "SNS – Use Cases" showing two rounded, colored cards. The left orange card reads "Securely encrypt notification message delivery" with a shield icon, and the right pink card reads "Capture and fan out events from over 60 AWS services" with a handshake icon.
Quick reference & next steps
  • 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.
Further reading Summary
  • 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.

Watch Video