Link Search Menu Expand Document

Image from @awsgeek

Simple Notification Service

SNS Basics

  • πŸ“’ Homepage βˆ™ Documentation βˆ™ FAQ βˆ™ Pricing
  • SNS (Simple Notification Service) is a pub/sub based, highly scalable, and fully managed messaging service that can also be used for mobile notifications.
  • SNS can push the messages down to the subscribers via SMS, Email, SQS, and HTTP/S transport protocols.
  • Producers publish messages to a SNS Topics, which can have many subscribers.
  • Each subscription has an associated protocol, which is used to notify the subscriber.
  • A copy of the message is sent to each subscriber using the associated protocol.
  • SNS can also invoke lambda functions.

SNS Alternatives and Lock-In

  • Popular alternatives to SNS are Kafka, Notification Hubs on Azure, and Pub/Sub on Google Cloud.
  • SNS vs SQS:
    • Both SNS and SQS are highly scalable, fully managed messaging services provided by AWS.
    • SQS supports a pull model, while SNS supports a push model. Consumers have to pull messages from an SQS Queue, while they're pushed the message from an SNS Topic.
    • An SQS message is intended to be processed by only one subscriber, while SNS topics can have many subscribers.
    • After processing, the SQS message is deleted from the queue by the subscriber to avoid being re-processed.
    • An SNS message is pushed to all subscribers of the topic at the same time, and is not available for deletion at the topic.
    • SNS supports multiple transport protocols of delivery of the messages to the subscribers, while SQS subscribers have to pull the messages off the queue over HTTPS.

SNS Tips

  • Fan-out architecture can be achieved by having multiple subscribers for a topic. This is particularly useful when events have to be fanned out to multiple, isolated systems.
  • SNS topics can be used to power webhooks with backoff support to subscribers over HTTP/S.
  • SQS queues can subscribe to SNS topics.
  • SNS is used to manage notifications for other AWS services like Autoscaling Groups' notifications, CloudWatch Alarms, etc.
  • SNS is frequently used as β€œglue” between disparate systemsβ€” such as GitHub and AWS services.

SNS Gotchas and Limitations

  • πŸ”Έ HTTP/S subscribers of SNS topics need to have public endpoints, as SNS does not support calling private endpoints (like those in a private subnet within a VPC).
  • πŸ“œ In a fan-out scenario, SSE-enabled SQS subscribers of an SNS topic will not receive the messages sent to the topic.