SNS & SQS
Last updated
Last updated
Amazon Simple Notification Service (Amazon SNS) is a managed service that provides message delivery from publishers to subscribers (also known as producers and consumers).
Publishers communicate asynchronously with subscribers by sending messages to a topic, which is a logical access point and communication channel.
Clients can subscribe to the SNS topic and receive published messages using a supported endpoint type, such as Amazon Kinesis Data Firehose, Amazon SQS, AWS Lambda, HTTP, email, mobile push notifications, and mobile text messages (SMS).
SNS Workflow
Simple Notification Service (SNS) sends the notifications through SMS or email to an Amazon Simple Queue Service (SQS), AWS lambda functions, or an HTTP endpoint.
When the CPU utilization of an instance goes above 80%, the AWS cloudwatch alarm is triggered.
This cloudwatch alarm activates the SNS topic hence notifying the subscribers about the high CPU utilization of the instance.
SNS service has a topic that has a unique name. It acts as a logical access point and a communication channel between publishers and subscribers.
SNS increases Durability.
SNS increases Security.
SNS ensures accuracy.
SNS reduces and simplifies the cost.
SNS supports SMS in over 200 countries.
Scalability: Simple Notification Service (SNS) had a capacity to handle millions of messages per second from the different sources.
Security: Simple Notification Service (SNS) is very secured and it also offers wide range of security offers.
High Availability: Simple Notification Service (SNS) is designed to have more durability which ensures the message are delivered without any latency.
Flexibility To Use: SNS supports a variety of transport protocols and can be used to send notifications to a variety of applications.
Go to the Amazon SNS dashboard. Click on Create Topic button.
Type in the name of the topic and description( optional ).
Type in the key value of the tag which is completely optional. Click on create the topic.
Congratulations!! The topic is created successfully.
Go back to the SNS dashboard. The created topic is visible in the dashboard now. Click on the link to the topic.
You will be redirected to this page. Under subscription options, Click on Create subscription.
Select the Protocol of the topic as Email and the endpoint of the topic as your email id. Click on Create Subscription.
Now go to the mailbox of the mentioned email id and click on Confirm subscription.
You will be directed to this page. Your subscription is confirmed.
Amazon Simple Queue Service (Amazon SQS) offers a secure, durable, and available hosted queue that lets you integrate and decouple distributed software systems and components.
Amazon SQS offers common constructs such as dead-letter queues and cost allocation tags.
SQS standards for Simple Queue Service offer asynchronous massaged-based communication between two services.
Before SQS the communication between the two services was based upon the API calls after the SQS the event producer will notify the consumer in an asynchronous manner.
The messages that are in the queue are in the form of Jason format and the queue is a holding pool of messages the limit of each message is 256 kilobytes per message.
The publishers will publish the messages into the queue and the messages are processed or removed with the help of consumers.
First-in-first-out(FIFO)
First-in-first-out(FIFO) queue the order of messages is preserved. So if you receive a message from the queue you will get the oldest message. This queue also guarantees that the message will be delivered only once.
Standard queue
Standard queue this queue messages are delivered randomly. Also, a message can be delivered multiple times. So you shouldn’t rely on order and only one-time delivery in this type of queues.
SQS is not push-based, it is basically on pull-based.
The size of messages in SQS are 256 KB.
There is default retention period in SQS. The default retention period is of 4 days.
Messages in SQS of a queue is kept from 1 minute to 14 days.
SQS also guarantees that the messages will only be processed at least once.
Open AWS console and type “SQS” in the search bar.
Then hit “Create queue”. You should see the following screen.
Every field has an Info clause.
Name the queue ‘Demo’ name and hit “Create Queue”. For other fields defaults are fine.
SQS is an message queuing service.
SNS is an publish/subscribe service.
It will transmit the data between distributed components.
It will distribute messages to multiple subscribers with the help of email,HTTP, AWS Lambda.
Used when you need to decouple the components.
Used to broadcast the data to all the subscribers.