Amazon Simple Notification Service (SNS) is a fully managed messaging service that enables publish-subscribe model of communication.

 

Key Components of Simple Notification Service (SNS)

There are two types of clients in SNS – Publishers and Subscribers

 

Publisher is a client that generates a set of messages. They are also called Producers.

  • Is typically an application or AWS resource that will generate a message notification

 

Subscriber is a client that receives the messages. They are also called Consumers.

  • Is also an application or AWS service that will consume the message, and decide what (if any) action to take based on the message
  • Subscriber must be registered with Topic to receive Message(s), and it can only receive Message(s) that are published after the time of its registration with the Topic
  • Supports following transport protocols
    • HTTP(S)
    • Email / Email-JSON (meant for programmatic consumption of email)
    • SQS (only standard queues; SQS FIFO is not supported)
    • SMS (can deliver text messages to 200+ countries)

 

Topic is a channel that acts as a registrar or broker, keeping a tab on list of Subscribers so it can deliver the messages sent to this channel to them.

 

Message is a unit of data sent to the Topic by Publisher(s). This is what is communicated from Publishers to Subscribers.

  • Message can only be text (plain, XML, JSON, etc.)
  • Message size limit is 256K
  • Filters may be applied to messages to streamline message distribution

 

Following diagram provides a simplistic view of how SNS works:

Simplistic view of how SNS works

Image courtesy of AWS

 

Key Points

  • SNS is an event-driven service based on Publish-Subscribe pattern
  • SNS is a Regional service, and is highly available within the Region
  • SNS stores multiple copies of the message across multiple AZs to provide message durability
  • SNS support CloudTrail, allowing log files of all the API calls made to SNS
  • SNS makes best attempt to deliver messages in the order received, but it is not guaranteed

 


Using SMS (Text Messages) with SNS

One of the supported protocol for SNS subscription is SMS (text messages to mobile phones).

  • Each SMS message can contain up to 140 bytes (character limit depends on the encoding scheme).
    • SNS sends multiple messages when a published message is larger than 140 bytes
  • SNS can deliver SMS messages to 200+ countries.
  • SMS messages can be marked transactional to increase their priority – such as in case of one-time passwords or PINs.
  • SNS only supports one-way SMS, except in case of opt-out messages (that can be received).
  • You can configure numbers to be used with SNS marking them as the “source” phone numbers.
  • SNS does not support scheduled delivery of SMS messages. You can however trigger additional functions (such as Lambda functions) to implement this logic.
  • Direct addressing allows you to deliver notifications directly to a single endpoint, rather than sending identical messages to all subscribers of a topic.

 

Following diagram shows how SMS works with SNS:

How SMS works with SNS

Image courtesy of AWS

 


Pricing

SNS is billed based on following components

  • Number of Notifications Published – per 1 million (first 1 million are free)
  • Number of Notifications Delivered
    • Mobile Push Notifications – per 1 million (first 1 million are free)
    • Email/ email-JSON – per 100,000
    • HTTP(S) – per million
    • SQS – standard SQS charges apply
    • Lambda functions – standard Lambda pricing applies
  • Data Transfer – standard AWS data transfer (out of AWS) charges apply
  • World-wide SMS (Text Messages) – varies by country of delivery

 


External Resources