Pushing Messages from the Cloud with Amazon Simple Notification Service
Amazon has launched a new service called Simple Notification Service (SNS) providing the means for setting up, publishing and sending notifications from the cloud, targeting monitoring applications, workflow systems, mobile applications or other notification-based applications.
Amazon has another notification service, Simple Queue Service (SQS), using a polling-based approach to messaging. SQS is used by distributed applications to communicate by sending messages to queues where they are stored awaiting to be consumed by clients. A client regularly polls a queue, retrieving any message of interest. This approach decouples the sender and the receiver of the message.
Unlike SQS, SNS uses a pushing approach to notification. An application or an administrator using a GUI tool creates a Topic or an Access Point identified by a subject or an event type. The owner of the topic determines who can publish/subscribe to it, and what protocol or protocols will be used for communication (HTTP, HTTPS, Email, Email-JSON, SQS queue). Clients interested in receiving messages will subscribe to these access points and will provide the URL or email address where notifications are to be sent. When an application wants to send a message, it sends it to the access point and SNS will take care of the delivering process.
Messages sent over Email will contain only the email’s message body as sent by the publisher and it is intended to be addressed to people who are supposed to read those messages. All other protocols use a JSON package meant for automatic processing and containing the following information:
- MessageId: A Universally Unique Identifier, unique for each notification published.
- Timestamp: The time (in GMT) at which the notification was published.
- Topic: The topic to which this message was published
- Type: The type of the delivery message, set to “Notification” for notification deliveries.
- UnsubscribeURL: A link to unsubscribe the end-point from this topic, and prevent receiving any further notifications.
- Message: The payload (body) of the message, as received from the publisher
- Subject: The Subject field – if one was included as an optional parameter to the publish API call along with the message.
- Signature: Base64-encoded “SHA1withRSA” signature of the Message, MessageId, Subject (if present), Type, Timestamp, and Topic values.
- SignatureVersion: Version of the Amazon SNS signature used.
If a message cannot be dispatched, the SNS system stores the message retrying to deliver it later until the client receives it. Messages are stored redundantly across multiple systems and data centers. Some of the other technical details to be considered are:
- SNS does not guarantee 100% delivery of messages to subscribers due to “potential Internet issues or Email delivery restrictions”. Amazon suggests sending the notifications to an SQS queue when delivery is critical.
- A subscriber could receive a message multiple times due to the distributed nature of the SNS system.
- SNS does not guarantee messages will be received in the exact order they were published.
- A message cannot be deleted after being published.
- Amazon has chosen to create its own API instead of using an open protocol like Advanced Message Queuing Protocol (AMQP) or even OASIS WS Notification (WSN). That means lock in into AWS.
Messages currently have a length of maximum 8KB and cost $0.06 for 100,000 notifications sent over HTTP and $2 for 100,000 emails. The first 100,000 HTTP notifications and 1,000 emails per month are free. SQS messages are not charged. Beside those fees, there are costs associated with data transfer IN/OUT Amazon SNS.
How Can We Use Our Creative Power and Technological Opportunity to Address the Challenges of the 21st Century?
Gyorgyi Galik Feb 26, 2015