Amazon Simple Notification Service (SNS) Overview

Amazon Simple Notification Service (SNS) is a web service that makes it easy to set up, operate, and send notifications from the cloud. It provides developers with capability to publish messages from an application and immediately deliver them to subscribers or other applications.

Amazon SNS follows the “publish-subscribe” (pub-sub) messaging paradigm, with notifications being delivered to clients using a “push” mechanism that eliminates the need to periodically check or “poll” for new information and updates.

 

Example Use Cases

The Amazon SNS service can support a wide variety of needs including monitoring applications, workflow systems, time-sensitive information updates, mobile applications, and any other application that generates or consumes notifications.

For example, Amazon SNS can be used in workflow systems to relay events among distributed computer applications deliver event updates and notifications to relevant system components as well as end-users. Another example use for Amazon SNS is to relay time-critical events to mobile applications and devices.

 

SNS Pub-Sub Process

  1. Developers must first create a “topic” which is an “access point” for publishing messages and allowing clients to subscribe for notifications.

  2. Once a topic is created, the topic owner can set policies for it such as limiting who can publish messages or subscribe to notifications, or specifying which notification protocols will be supported (i.e. HTTP/HTTPS, email, SMS).

  3. Subscribers can subscribe to a topic or be subscribed by the topic owner. Subscribers specify the protocol and end-point (URL, email address, etc.) for notifications to be delivered.

  4. Publishers publish a message to the topic, which immediately triggers Amazon SNS to deliver the message to all applicable subscribers.

 

Subscription Confirmation Process

Users can receive notifications from Amazon SNS in two ways:

  1. Users with AWS IDs: Subscribers with valid AWS IDs can subscribe to any topic directly – as long as the topic owner has granted them permissions to do so.

  2. Other users: Topic owners can subscribe and register end-points on behalf of users without AWS IDs.

In any case, subscribers have to explicitly opt-in before they receive any notification, to prevent spams.

The exact mechanism of confirming the subscription varies by the transport protocol selected:

  1. For HTTP/HTTPS notifications, Amazon SNS will first POST the confirmation message (containing a token) to the specified URL. The application monitoring the URL will have to call the ConfirmSubscription API with the token included token.

  2. For Email and Email-JSON notifications, Amazon SNS will send an email to the specified address containing an embedded link. The user will need to click on the embedded link to confirm the subscription request.

  3. For SQS notifications, Amazon SNS will enqueue a challenge message containing a token to the specified queue. The application monitoring the queue will have to call the ConfirmSubscription API with the token. Note: Not required is both are “owned” by the same AWS account.

Note: Token included in the confirmation message sent to end-points on a subscription request are valid for 3 days.

 

SNS Unsubscription Process

A subscription that was confirmed with the AuthenticateOnUnsubscribe flag set to True in the call to the ConfirmSubscription API call can only be unsubscribed by a topic owner or the subscription owner. If the subscription was confirmed anonymously without the AuthenticateOnUnsubscribe flag set to True, then it can be anonymously unsubscribed.

In all cases except when unsubscribed by the subscription owner, a final cancellation message will be sent to the end-point, allowing the endpoint owner to easily re-subscribe to the topic.

 

ARN

When a topic is created, SNS will assign a unique ARN to the topic, which will include the service name (SNS), region, AWS ID of the user and the topic name. The ARN will be returned as part of the API call to create the topic. Whenever a publisher or subscriber needs to perform any action on the topic, they should reference the unique topic ARN.

E.g. arn:aws:sns:us-east-1:1234567890123456:mytopic

This is the ARN for a topic named “mytopic” created by a user with the AWS account ID “123456789012” and hosted in the US East region. Note: Users should NOT attempt to build the topic ARN from its separate components – they should always use the name returned from the API call to create the topic.

 

SNS – Limits

  1. By default, SNS offers 10 million subscriptions per topic, and 100,000 topics per account.  Can request a higher limit.

  2. With the exception of SMS messages, Amazon SNS messages can contain up to 256 KB of text data, including XML, JSON and unformatted text.

  3. The following Unicode characters are accepted: #x9 | #xA | #xD | [#x20 to #xD7FF] | [#xE000 to #xFFFD] | [#x10000 to #x10FFFF]

  4. Each 64KB chunk of published data is billed as 1 request. For example, a single API call with a 256KB payload will be billed as four requests.

  5. SMS messages: Each SMS message can contain up to 140 bytes, and the character limit depends on the encoding scheme. For example, an SMS message can contain: 160 GSM characters, 140 ASCII characters and 70 UCS-2 characters.

  6. If you publish a message that exceeds the size limit, Amazon SNS sends it as multiple messages, each fitting within the size limit. Messages are not cut off in the middle of a word but on whole-word boundaries. The total size limit for a single SMS publish action is 1600 bytes.

  7. Cross-region communication between SNS and EC2 on ports other than 80/443/4080/8443 is not guaranteed to work and should be avoided.

 

SNS Pricing

  1. With Amazon SNS, there is no minimum fee and you pay only for what you use. Users pay for SNS Requests and Notification deliveries over HTTP, email, sms.

  2. SNS Free Tier provide first 1 million SNS Requests, 1 million mobile push deliveries,  100,000 Notifications over HTTP, 100 Notifications over SMS and 1,000 Notifications over Email, as free.

  3. The SNS free tier includes 1 million publishes, plus 1 million mobile push deliveries.

  4. No charge for deliveries to SQS Queues and Lambda.

  5. Each 64KB chunk of published data is billed as 1 request.

 

SNS – Important Notes (Exam Tips)

  1. Topic names are limited to 256 characters and can contain alphanumeric characters, hyphens (-) and underscores (_).

  2. Topic names must be unique within an AWS account. After you delete a topic, you can reuse the topic name. There might be a delay of 30-60 seconds before it become available after delete.  

  3. SNS JSON messages can contain parameters like message, signature, subject, type etc. It will not include info such as source and destination. 

  4. Currently the Delivery Status feature is available for mobile push notifications and SMS.

  5. By default, SNS offers 10 million subscriptions per topic. Can ask for higher limit.

  6. All messages are stored redundantly on multiple servers and in multiple data centers.

  7. All notification messages will contain only a single published message.

  8. Once a message has been successfully published to a topic, it cannot be recalled.

  9. Amazon SNS is HIPAA eligible.

  10. SNS Mobile Notifications makes it simple and cost effective to send push notifications to iOS, Android, Fire OS, Windows and Baidu-based devices.

  11. You can also use SNS to send push notifications to MacOS desktops and Voice over IP (VoIP) apps on iOS devices, emails, and SMS messages to 200+ countries.

  12. With SNS, it's easy to send updates, promos, or news to individual users, a subset of users, or all of your users, using a single message.

Contact

Please first use the contact form or facebook page messaging to connect.

Offline Contact
We currently connect locally for discussions and sessions at Bangalore, India. Please follow us on our facebook page for details.
WhatsApp (Primary): (+91) 7411174113
Phone (Escalations): (+91) 7411174114

Business newsletter

Complete the form below, and we'll send you an e-mail every now and again with all the latest news.

About

CloudMaterials.com is my blog to share notes and learning materials on Cloud and Data Analytics. My current focus is on Amazon Web Services.

I like to write. I try to document what I learn and share with others. I believe that knowledge is useless unless you share it; the more you share, the more you learn.

Recent comments

Photo Stream

,