Amazon Simple Notification Service (SNS) vs. Simple Queue Service (SQS)

Blog > Amazon Simple Notification Service (SNS) vs. Simple Queue Service (SQS)

Amazon Simple Notification Service (SNS) vs. Simple Queue Service (SQS)

What is AWS SQS (Simple Queue Service)?

Amazon Simple Queue Service (Amazon SQS) is a distributed message queuing service. It supports the programmatic sending of messages via web service applications to communicate over the internet. SQS is intended to provide a highly scalable hosted message queue service that resolves issues arising from the common producer-consumer problem or connectivity between producer and consumer. It supports standard Queue and FIFO queue. It is a service that handles the delivery of messages between components.

SQS processes a large number of messages without losing a single message with less hardware configuration.

SQS Components

Producer: Producer components of users’ application architecture are responsible for sending messages to Queue. At this point, the SQS service stores the message across several SQS servers for resiliency within the specified gear; this ensures that the message remains in Queue if a failure occurs with one of the SQS servers’.

Consumer: The consumers are responsible for processing the messages within the key when the consumer element of users’ architecture is ready to process a message from the Queue. The message is retrieved and marked that the process has been processed by activating the visibility timeout on the message. This timeout ensures that the same message will not be read and processed by another consumer. When the message has been processed, the consumer then deletes the message from the Queue.

Visibility Timeout

When the consumer retrieves a message, the visibility timeout is started. The default time is 30 seconds. It can be set up for as long as 12 hours. If the visibility timeout expires, the message will become available again in the Queue for other consumers to process.

What is AWS SNS?

SNS is a notification service provided as part of Amazon web services. It’s a Message publishing and processing service (PubSub). This service provides a low-cost infrastructure for the mass delivery of messages, predominantly to mobile users. From the sender’s viewpoint, SNS acts as a single message bus that can message various devices and platforms. Simple Notification service SNS can also deliver messages to 200+ countries. SNS uses the publish/subscribe model for push delivery of messages.

In AWS SNS, there are two types of clients

  • Publishers (Producers)
  • Subscribers (Consumers)

Topic

An Amazon SNS topic is a logical access point that acts as a communication channel. A topic lets its users group multiple endpoints (such as AWS Lambda, Amazon SQS, HTTP/S, or an email address).

Subscribers

Subscribers (web servers, email addresses, Amazon SQS queues, AWS Lambda functions) consume or receive the message or notification over one of the supported protocols (Amazon SQS, HTTP, email, SMS, Lambda) when users subscribe to a topic.

Technical Comparison

Simple Notification Service Simple Queue Service
SNS stands for simple notification service SQS stands for simple queue service
Publisher / Subscriber System Queueing service for message processing
Publishing messages to a topic can deliver to many subscribers of different types (SQS, Lambda, Email) A system must poll the Queue to discover new events. A single consumer typically processes messages in the Queue.
Scale Automatically Scales Automatically
Keep messages secure using AWS KMS keys Keep messages secure using AWS KMS keys
Messages can go to different subscribers based on fields in the message (Message Filtering) Reliable, Dead letter Queues can be enabled
Fan Out Architecture – The same message can be consumed by multiple consumers Convert synchronous pattern to asynchronous. One message cannot have multiple consumers. Once a message is processed by the consumer, it gets deleted from SQS.
SNS is centered around topics. User can use the topic as a group for collecting messages SQS is a fully managed service that works with a serverless system, microservices, and distributed architectures
Users or endpoints can then subscribe to this topic, where messages or events are published It has the capability of sending, storing, and receiving messages at scale without dropping message data
When a message is published, all subscribers to that topic receive a notification of that message It is possible to configure the service using the AWS Management Console, the AWS CLI, or AWS SDKs.

If you have any questions about integrating AWS Simple Notification Service (SNS) and Simple Queue Service, feel free to contact Silicon Valley Cloud IT professionals for a free consultation.

Author: SVCIT Editorial
Copyright Silicon Valley Cloud IT, LLC.

Svcit Silicon Valley Cloud IT LLC. + 1 (855)-MYSVCIT Customers@SiliconValleyCloudIT.com