Amazon SNS (Simple Notification Service) offered by AWS (Amazon Web Services) is an overseen service that provides message delivery or sending of messages to subscribing endpoints or clients. It is a completely controlled messaging service that is highly available, durable, and secure.
This post will cover everything that you need to understand about Amazon SNS:
- What is Amazon SNS
- Features of Amazon SNS
- Types of SNS Topics
- Amazon SNS Clients
- Benefits of SNS
- Steps to Configure SNS
- Amazon SNS Pricing
- Amazon SNS Security
- Difference between SNS and SQS
- Frequently Asked Questions
What is Amazon SNS
Amazon SNS stands for Simple Notification Service, which is utilized to convey the push messages from the application to the subscribing ends or other applications. It is a completely managed messaging service for both application to application (A2A) and application to person (A2P) communication. It provides the ability to create a Topic that is a logical access point and communication channel. Each topic has a different name that identifies the SNS endpoint for publishers to post messages and subscribers to register for notifications.
Feature of Amazon SNS
- Automatic Scaling: It scales consequently if the number of messages increases.
- Message Encryption: It provides encrypted topics to protect your messages from unapproved and unknown access. The message gets decrypted as they are delivered to subscribing endpoints.
- Message Filtering: It enables the subscriber to modify a filter policy so that it only gets the notifications it is interested in.
- Message Fanout: It takes place when a message is sent to a topic and then replicated and pushed to multiple endpoints. Fanout gives asynchronous event notifications, which in turn allows for parallel processing.
- Mobile Notification: It can be activated by user-driven actions within an application or from business logic within the cloud. It is low-cost to fanout mobile push notifications for iOS, Android, Fire OS, Windows, and Baidu-based devices.
- SNS & Email Messages: Amazon SNS provides the features to send text messages and email (SMTP).
Types of SNS Topics
There are 2 types of SNS Topics:
- Standard Topic
- FIFO Topic
Difference between Standard and FIFO Topic
- Standard Topic is used in many scenarios where the order of message is not important while FIFO Topic used in messaging between applications where the order of operations and event is critical.
- Standard Topic supports a nearly unlimited number of messages per second whereas FIFO Topic supports up to 300 messages per second or 10 MB per second per FIFO topic.
- In standard topic, a message is delivered at least once, but there might be more than one copy of a message is delivered but in FIFO topic, duplicate messages are not delivered.
- In standard topic, each account can support 100K standard topic and each topic support up to 12.5M Subscriptions whereas in FIFO topic, Each account can support 1000 FIFO topics and each topic supports up to 100 Subscriptions.
Amazon SNS Clients
There are two clients of SNS:
- Subscribers
- Publishers
Subscribers
Subscribers receive the required message or notification over one of the supported protocols (Amazon SQS, email, Lambda, HTTP, SMS) when they are subscribed to the topic.
Publishers
Publishers are also known as producers, publishers communicate asynchronously with subscribers by producing and sending a message to a topic, which is a logical access point and communication channel.
Benefits of SNS
- Instantaneous Delivery: It is based on push-based delivery. It is pushed once we publish the message on a topic and the message is delivered to multiple subscribers.
- Inexpensive: It is based on pay as you use the model, i.e. we need to pay only when we are using the resources with no up-front costs.
- Flexible: It supports multiple endpoints. Various endpoint types can receive the message over multiple transport protocols such as email, SMS, Lambda, Amazon SQS, HTTP, etc.
- Ease of use: It is a very simple service to use as Web-based AWS Management Console offers the effortlessness of the point-and-click interface.
- Simple Architecture: SNS is utilized to simplify the messaging architecture by offloading the message filtering logic from the subscribers and message routing logic from the publishers. Rather than receiving all the messages from the topic, SNS sends the message to subscriber-only of their interest.
Steps to Configure Amazon SNS
In these steps, we are going to configure Amazon SNS. For creating AWS Free Tier Account click here: AWS Free Tier Account Services.
1) Search SNS in the search bar and click on it. Afterward, click on the Topics on the top left side of the Console and then Click on Create Topic to create a new topic.
2) Enter the Topic name. Scroll down and click on Create Topic.
3) Now, the Topic has been created successfully. Scroll down and click on Create Subscription.
4) Under Protocol choose the endpoint as Email and enter the Endpoint address, click on Create Subscription. Now, the subscription will be created and the status of the subscription is pending.
5) The email will be sent to the subscriber for confirmation of the subscription. The subscriber has to open the email and click on Confirm Subscription. After this subscription will be confirmed.
6) Now, the status of the subscription will be confirmed, and then click on Topic name. After that click on Publish Message.
7) Enter the subject name, message body. Scroll down and click on Publish Message.
8) Now, the subscriber will receive the message on the mentioned email address.
Amazon SNS Pricing
By default, Amazon SNS comes with a generous free tier, and it’s also inexpensive. There is no need for a subscription, you simply pay for what you use at the type of endpoint you choose. Each month we will get 1 million free mobile push notifications. Afterward, each delivered message is charged at $0.5 per million, it also depends upon the region of your recipient.
Amazon SNS Security
- SNS provides encrypted topics to protect messages from unapproved and mysterious access. The encryption occurs on the server-side.
- Amazon SNS supports VPC Endpoints via AWS PrivateLink. We can utilize VPC Endpoints to privately publish messages to SNS topics, from a VPC, without traversing the public internet.
- Utilizing access policies, you have point-by-point control over which endpoints a topic allows, who is able to publish to a topic, and under what conditions.
- You can enable AWS X-Ray for your messages passing through Amazon SNS, making it simpler to trace and analyze messages as they travel through to the downstream services.
Difference between SNS and SQS
Amazon SQS (Simple Queue Service) is a fully managed message queuing service that empowers us to decouple and scale microservices, distributed systems, and serverless applications. By using SQS, you can send, store, and receive messages between software components at any volume, without losing messages or requiring other services to be available. Amazon SNS works closely with Amazon SQS.
But there is a lot of confusion between them. So let’s see the difference between them
Frequently Asked Question
Q1. When does billing of my Amazon SNS use begin and end?
Ans. Your Amazon SNS billing cycle starts on the first day of each month and ends on the last day of each month. Your monthly charges will be totaled at the end of each month.
Q2. How long will subscription requests remain pending, while waiting to be confirmed?
Ans. Token included in the confirmation message sent to end-points on a subscription request is valid for 3 days.
Q3. Is Amazon SNS free?
Ans. It has no upfront costs and you can pay as you go.
Q4. What is the format of an Amazon SNS topic?
Ans. Topic names are restricted to 256 characters. Alphanumeric characters plus hyphens (-) and underscores (_) are allowed. Topic names have to be unique within an AWS account. After we delete a topic, you can reuse the topic name. When a topic is created, Amazon SNS will assign a unique ARN (Amazon Resource Name) to the topic, which will include the service name (SNS), region, AWS ID of the user, and the topic name.
Related Links/References
- AWS Certified Solutions Architect Associate SAA-C02
- Overview of Amazon Web Services & Concept
- How to create a free tier account in AWS
- AWS Certified DevOps Engineer Professional DOP-C01
- AWS Management Console Walkthrough
Next Task For You
Begin your journey towards becoming a Certified AWS Solution Architect Associate by joining our FREE Informative Class on Amazon AWS Solution Architect Certification For Beginners & Q/A by clicking on the below image.
The post Amazon Simple Notification Service (SNS) appeared first on Cloud Training Program.