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 AWS SNS
- Features
- Types of AWS SNS Topics
- Amazon SNS Clients
- Benefits
- Steps to Configure SNS
- AWS SNS Pricing
- Amazon SNS Security
- AWS SNS vs SQS
- Frequently Asked Questions
What is AWS 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 applications-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.
Also, Read Our Blog post on AWS Secrets Manager.
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 fan out 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).
Read Our Blog on AWS Storage for an overview of and types of storage options offered.
Types of AWS SNS Topics
There are 2 types of AWS SNS Topics:
- Standard Topic
- FIFO Topic
Difference between Standard and FIFO Topic
- Standard Topic is used in many scenarios where the order of messages is not important while FIFO Topic is used in messaging between applications where the order of operations and events 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 a standard topic, a message is delivered at least once, but there might be more than one copy of a message delivered but in a 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.
Also, check our blog post on AWS lambda.
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.
Check Also: Free AWS Training and Certifications
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.
Also, Read Our previous blog post on AWS EC2 Auto Scaling. Click here
Benefits of AWS 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 the 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.
Also, Read Our blog post on AWS IoT. Click here
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
1) Search SNS in the search bar and click on it. Afterwards, click on the Topics on the top left side of the Console and then Click on Create Topic to create a new topic.
2) Select Standard type and 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 the Topic name. After that click on Publish Message.
7) Enter the subject name and message body. Scroll down and click on Publish Message.
8) Now, the subscriber will receive the message on the mentioned email address.
AWS SNS Pricing
By default, AWS 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.6 per million, it also depends upon the region of your recipient. Every time a 64KB portion of data is sent, it counts as one request for billing purposes. To illustrate, if a message with a 256KB size is sent, it would be charged as four requests.
Also, Read Our blog post on AWS WAF. Click here
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.
AWS SNS vs 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. AWS SNS works closely with Amazon SQS.
But there is a lot of confusion between them. So let’s see the difference between them
Also Check Azure vs GCP vs AWS, to know the major differences between them.
Frequently Asked Questions
When does billing of my Amazon SNS use begin and end?
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 totalled at the end of each month.
How long will subscription requests remain pending, while waiting to be confirmed?
Token included in the confirmation message sent to end-points on a subscription request is valid for 3 days.
Is Amazon SNS free
It has no upfront costs and you can pay as you go.
What is the format of an AWS SNS topic?
1. Topic names are restricted to 256 characters.
2. Alphanumeric characters plus hyphens (-) and underscores (_) are allowed.
3. Topic names have to be unique within an AWS account.
4. 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 Free Tier Limits
- AWS Free Tier Account Details
- How to create a free tier account in AWS
- AWS Certified Solutions Architect Associate SAA-CO3
- Amazon Elastic File System User Guide
- AWS Free Tier Account Services
- AWS Route 53 Introduction
Next Task For You
Begin your journey towards an AWS Cloud by joining our FREE Informative Class on Amazon Cloud Free Class by clicking on the below image.
Nitesh says
Hi , If i am sending a message using python by consumin SNS client directly to a phone number rather creating topic and subscription , then how i can send failed message to dead letter queue.
Rahul Dangayach says
Hi Nitesh,
To configure a dead-letter queue for an existing queue (console)
1. Open the Amazon SQS console at https://console.aws.amazon.com/sqs/
2. In the navigation pane, choose Queues.
3. Choose a queue and choose Edit.
4. Scroll to the Dead-letter queue section and choose Enabled.
5. Choose the Amazon Resource Name (ARN) of an existing Dead Letter Queue that you want to associate with this source queue.
6. To configure the number of times that a message can be received before being sent to a dead-letter queue, set Maximum receives to a value between 1 and 1,000.
7. When you finish configuring the dead-letter queue, choose Save.
8. After you save the queue, the console displays the Details page for your queue. On the Details page, the Dead-letter queue tab displays the Maximum Receives and Dead Letter Queue ARN in the Dead-letter queue.
Link: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-configure-dead-letter-queue.html
Hope this helps.
Thanks and Regards
Rahul Dangayach
Team K21 Academy