Thursday, December 26, 2024
Google search engine
HomeData Modelling & AIHow Does Amazon SNS Work?

How Does Amazon SNS Work?

This article was published as a part of the Data Science Blogathon.

Introduction

Amazon Simple Notification Service (SNS) is a managed service that delivers messages from publishers to subscribers (also known as producers and consumers). Publishers communicate asynchronously by sending messages on a topic that serves as a logical access point and communication route for subscribers. Clients can subscribe to an SNS topic and receive published messages via any supported endpoint, including Amazon Kinesis Data Firehose, Amazon SQS, AWS Lambda, HTTP, email, mobile push notifications, and mobile text messaging (SMS).

Amazon SNS
Source: -https://aws.amazon.com

 

What is Amazon SNS?

The Simple Notification Service (Amazon SNS) sends push notifications from the application to subscriber end users or other programs. It is a fully messaging service for communication between applications (A2A) and people (A2P). It allows you to create a topic as a logical access point and communication channel. Each subject has a unique name that specifies the SNS endpoint where publishers can send messages and subscribers can subscribe to notifications.
Source: -https://aws.amazon.com

 

Features of the Amazon Simple Notification Service

These are some of the Features of SNS

  • Auto-scaling: As the volume of messages grows, it scales accordingly.
  • Message Encryption: Protects your messages using encrypted themes from unwanted and unknown access. When messages are transmitted to subscriber endpoints, they are decrypted.
  • Message filtering: This allows the subscriber to change the filtering policy so that he only receives relevant notifications.
  • When a message is sent to a topic, it is replicated and sent to multiple endpoints, called message branching. Asynchronous event notification is provided by Fanout, allowing for parallel processing.
  • Mobile Notification: User-initiated in-app actions or cloud-based business logic can be triggered. Distributing mobile push notifications for iOS, Android, Fire OS, Windows, and Baidu-based devices are cheap.
  • SNS and Email Messaging: Amazon SNS can send text and email messages (SMTP).

How does AWS SNS Work?

As mentioned earlier, AWS SNS sends messages to its endpoints using the Publisher-Subscriber paradigm. You can use Amazon SNS to filter messages for a larger number of subscribers or endpoints through mobile communications, SMS, and email.
  • Publishers, also known as producers, create and send messages to AWS SNS.
  • On the other hand, subscribers receive messages published by the SNS using supported network protocols such as Amazon SQS, AWS Lambda, or HTTP/HTTPS.
  • Below are the exact stages of the workflow that AWS SNS implements:
  • The publisher first sends the required notifications to the subscribers.
  • SNS Topic – Used to filter out messages that need to be distributed to different subscribers. As an AWS developer, you must create an SNS topic that will serve as a subscriber access point. Subscribers can receive news alerts on a selected topic using a topic.
  • The message is delivered to the subscriber via subscriber queues or microservices. To receive a message, subscribers must submit valuable information such as a URL, email address, or phone number. Below are some of the most common forms of SNS messages:
  • Automatic user alerts triggered by predefined thresholds and sent to specific users via SMS or email are known as application and system alerts.
  • Push email or text messages are two ways to communicate with people or groups (for example, news article alerts sent to newspaper subscribers).
  • Mobile push notifications are messages sent directly to mobile applications (for example, notification of any application update available for installation).

How does Amazon SNS Message Filtering Work?

How Amazon SNS uses message filtering to deliver only a subset of SNS topic messages to subscriber endpoints. For example, consider a company website that sends user queries to many backend servers.
Amazon SNS

Source:-https://docs.aws.amazon.com

 

This server network consists of:
  • First, 1 server to handle requests from “Type 1” users.
  • Second, 1 server to handle “type 2” user requests.
  • 1 data analysis server handles both “Type 1” and “Type 2” user requests.
  • Following are the six stages of implementing message filtering with Amazon SNS:
  • Create an Amazon SNS topic
  • The first step is to set up an Amazon SNS topic to send messages whenever a user requests the site.
  • Use the “AWS Services” search box to find the Amazon SNS console.
  • Click “Get Started with an Overview” on the SNS Console landing page, then click “Topics” from the left-hand menu.
  • Then, in the dialog box, click “Create Topic” and enter the name of your topic (“Topic 1”) in the “Topic Name” field (shown below).
  • To create and add a new topic to the “Topic” detail page, click “Create Topic” in the dialog box above.

Create Amazon SQS Queues

  • The next step is creating Amazon SQS queues that subscribe to the SNS topic. Backend web servers query user requests from the corresponding SQS message queue. For this example:
  • Queue_1 processes requests from “type 1” users.
  • Queue_2 handles requests from “type 2” users.
  • Queue_3 handles both “Type 1” and “Type 2” user requests.
  • Sign in to the AWS SQS console using your username and password.
  • Then enter the Ques’ name as “Queue 1” in “Queue Name.” Click on “Quick-Create Queue” with “Standard Queue” selected.
Repeat step b to create two new queues named “Queue 2” and “Queue 3”. All three SQS queues are listed on the SQS console page once created.

Benefits of Amazon Simple Notification Service

The benefits of AWS SNS are as follows:

  • Instant delivery: Works on a push-based system. It is sent once a message is posted on a topic and forwarded to many subscribers.
  • It’s cheap because it’s built on a pay-as-you-go basis, which means we only pay when we use the resources and you don’t pay any upfront fees.
  • Multiple endpoints are supported, making it versatile. Different endpoints can receive messages via different transport protocols, including email, SMS, Lambda, Amazon SQS, HTTP, and more.
  • Ease of use: The AWS web management console offers the simplicity of a point-and-click interface, making it a very straightforward service.

Amazon SNS Pricing

Amazon SNS comes standard with a generous free tier and is reasonably priced. No subscription is required; you simply pay for the services you use on your chosen endpoint type. We will be sent 1 million free mobile push notifications every month. After that, each delivered message is charged $0.5 per million, depending on the recipient’s area.

What is Amazon SNS Security?

Let’s see the Security of AWS SNS

  • To protect messages from unwanted and unexplained access, SNS offers encrypted topics. Encryption takes place on the server.
  • Amazon SNS supports VPC endpoints through AWS Private Link. We can use VPC endpoints to send messages to SNS topics from the VPC without going over the public Internet.
  • Use access policies to limit which endpoints a topic allows, who has permission to publish the topic, and under what conditions.
  • You can enable AWS X-Ray for messages traveling through Amazon SNS, making it much easier to track and analyze messages traveling to downstream services.
  • Advantages of SNS
  • Instant delivery: Push-based delivery is the foundation of SNS. This is the most significant difference between SNS and SQS. When you post a message on a topic distributed to several subscribers, SNS is a push.
  • Flexible: Flexible SNS supports multiple types of endpoints. Different endpoints can receive messages via different transport protocols, including email, SMS, Lambda, Amazon SQS, HTTP, and more.
  • Inexpensive: The SNS service is low cost because it is built on a pay-as-you-go basis, meaning you only pay when you use the resources, and there are no upfront costs.
  • User-friendliness.
  • Ease of use: SNS is straightforward with a point-and-click web-based AWS management console interface.
  • Simple architecture: SNS is used to simplify the messaging architecture by offloading message filtering and routing complexity from subscribers and publishers.

Conclusion

Amazon SNS is intended to be used with other Amazon Web Services, such as Amazon SQS and EC2. For example, applications running on Amazon EC2 can publish event/information changes to Amazon SNS and immediately distribute them to all other end users. In addition, the subscriber can choose Amazon SQS as the delivery mechanism that sends notifications to different SQS queues in parallel, providing message persistence and formal assurance that messages are delivered. If you use Amazon SNS, you should enable it on your mobile devices to use its features.
  • Features of AWS SNS include:- Auto-Scaling, Message Filtering, Mobile Notification, SMS, and Email messaging.
  • It allows you to create a topic as a logical access point and communication channel. Each subject has a unique name that specifies the SNS endpoint where publishers can send messages and subscribers can subscribe to notifications.
  • To protect messages from unwanted and unexplained access, SNS offers encrypted topics. Encryption takes place on the server. Amazon SNS supports VPC endpoints through AWS PrivateLink. We can use VPC endpoints to send messages to SNS topics from the VPC without going over the public Internet.
  • The SNS service is low cost because it is built on a pay-as-you-go basis, meaning you only pay when you use the resources, and there are no upfront costs.

 The media shown in this article is not owned by Analytics Vidhya and is used at the Author’s discretion.

Chetan Dekate

21 Aug 2022

RELATED ARTICLES

Most Popular

Recent Comments