top of page

Download free e-books

Explore the world of Software and Data Engineering in a more efficient and accessible way with our eBooks!

  • Writer's pictureJP

Overview about AWS SNS - Simple Notification Service



SNS (Simple Notification Service) provides a notification service based on Pub/Sub strategy.

It's a way of publishing messages to one or more subscribers through endpoints. Is that confuse?


Let's go deeper a little more about this theme. Usually the term Pub/Sub is related to event-driven architectures. In this architecture publishing messages can be done through notifications to one or more destinations already known, providing an asynchronous approach. For a destiny to become known, there must be a way to signal that the destination becomes a candidate to receive any message from the source.


But how does subscriptions work? For SNS context, each subscriber could be associated to one or more SNS Topics. Thus, for each published message through Topic, one or more subscribers will receive them.


We can compare when we receive push notifications from installed apps in our smartphones. It's the same idea, after an installed app we became a subscriber of that service. Thus, each interaction from that application could be done through notifications or published messages.



The above example demonstrates a possible use case that SNS could be applied. For the next sections we'll discuss details for a better understanding.


SNS basically provides two main characteristics, Publishers and Subscribers. Both of them work together providing resources through AWS console and APIs.



1. Topics/Publishers


Topics are logical endpoints that works as an interface between Publisher and Subscriber. Basically Topics provides messages to the subscribers after published messages from the publisher.


There are two types of Topics, Fifo and Standard:


  • Fifo: Fifo type allows messages ordering (First in/First out), has a limit up to 300 published messages per second, prevent messages duplication and supports only SQS protocols as subscriber.


  • Standard: It does not guarantee messages ordering rules and all of the supported delivery protocols can subscribe to a standard topic such as SQS, Lambda, HTTP, SMS, EMAIL and mobile apps endpoints.


Limits


AWS allows to create up to 100.000 topics per account.


2. Subscribers


The subscription is a way to connect an endpoint to a specific Topic. Each subscription must have associated to a Topic to receive notifications from that Topic.


Examples of endpoints:

  • AWS SQS

  • HTTP

  • HTTPS

  • AWS Kinesis Data Firehose

  • E-mail

  • SMS

  • AWS Lambda

These above endpoints are examples of delivery or transportation formats to receive notifications from a Topic through a subscription.


Limit Subscriptions


AWS allows up to 10 millions subscriptions per Topic.


3. Message size limit


SNS messages can contain up to 256 KB of text data. Different of the SMS that can contain up to 140 bytes of text data.



4. Message types


SNS supports different types of messages such as text, XML, JSON and more.


5. Differences between SNS and SQS


Sometimes people get confused about the differences but don't worry I can explain these differences. SNS and SQS are different services but they can be associated. SQS is an AWS queue service that retains sent messages from the different clients and contexts, but at the same time they can works as a subscriber to a Topic. Thus, a SQS protocol subscribed to a Topic will start receiving notifications, becoming an asynchronous integration.



Look at the image above, we're simulating a scenario that we have three SQS subscribed in three Topics. SQS 1 is a subscriber to the Topic 1 and 2. Thus, SQS 1 will receive notifications/messages from the both Topics, 1 and 2. SQS 2 is another subscriber to the Topic 2 and 3 that automatically also will receive messages from Topic 2 and 3. And for the last one case, we have SQS 3 as a subscriber to the Topic 3 that will receive messages only from Topic 3.


For more details I recommend read this doc.

 

Books to study and read


If you want to learn more about and reach a high level of knowledge, I strongly recommend reading the following book(s):


AWS Cookbook is a practical guide containing 70 familiar recipes about AWS resources and how to solve different challenges. It's a well-written, easy-to-understand book covering key AWS services through practical examples. AWS or Amazon Web Services is the most widely used cloud service in the world today, if you want to understand more about the subject to be well positioned in the market, I strongly recommend the study.















Well that’s it, I hope you enjoyed it!


Comments


bottom of page