What is Amazon Simple Queue Service (SQS)?

  1. Home
  2. AWS
  3. What is Amazon Simple Queue Service (SQS)?
Amazon Simple Queue Service (SQS)

With the growing technology and services, organizations are finding ways to manage and scale their services, systems, and applications. In order to help these organizations, AWS provides a Simple Queue Service (SQS). By providing a secure, durable, and available hosted queue, Amazon Simple Queue Service (Amazon SQS) helps in integrating and decoupling distributed software systems and components. Interesting right? Now, let’s make it more interesting by understanding a brief about Amazon Simple Queue Services, features, and how to get started with this. So, let’s begin!

Amazon SQS: Overview

Amazon SQS refers to a message queuing service that is used for decoupling and scaling microservices, distributed systems, and serverless applications. SQS removes the complexity and overhead linked with managing and operating message-oriented middleware and empowers developers for focusing on differentiating work. Moreover, with this service, you can send, store, and receive messages between software components at any volume, without any message loss or requiring other services to be available. 

Further, Amazon SQS provides common constructs like dead-letter queues and cost allocation tags. It provides a generic web services API that can be accessed using any programming language that the AWS SDK supports. However, there are two types of message queues in SQS. 

  • Firstly, Standard queues. This provides maximum throughput, best-effort ordering, and at least one delivery. 
  • Secondly, SQS FIFO queues. This provides a guarantee that messages are processed exactly once and in the same order that they are sent.
Amazon Simple Queue Service (SQS)

Benefits of using Amazon SQS

  • Firstly, in SQS, you control who can send messages to and receive messages.
  • Secondly, the Server-side encryption (SSE) feature lets you transmit sensitive data by protecting the contents of messages in queues using keys managed in AWS Key Management Service.
  • Thirdly, Amazon SQS stores message on multiple servers for safety. Moreover, it redundant infrastructure for providing highly-concurrent access to messages and high availability for producing and consuming messages.
  • Fourthly, Amazon SQS can process each buffered request independently, scaling transparently for handling any load increases without any provisioning instructions.
  • Next, it has the ability to lock your messages during processing. This is so that multiple producers can send and multiple consumers can receive messages at the same time.
  • In SQS, there is:
    • Firstly, no upfront cost
    • Secondly, no need to acquire, install and configure messaging software
    • Lastly, no time-consuming build-out and maintenance of supporting 
  • After that, you can use Amazon SQS for transmitting any volume of data, at any level of throughput, without losing messages or requiring other services to be available. Moreover, it allows decoupling of application components for running independently, thus, increasing the overall fault tolerance of the system. 
  • Lastly, Amazon SQS supports the AWS cloud to dynamically scale depending on demand. Moreover, it scales elastically with your application and there is no limit to the number of messages per queue, and standard queues provide nearly unlimited throughput.
Differentiating Amazon SQS, Amazon MQ, and Amazon SNS:

Amazon SQS and Amazon SNS refer to queue and topic services that are highly scalable, easy to use, and do not require setting up message brokers. These services are best for new applications that can benefit from nearly unlimited scalability and simple APIs. On the other hand, Amazon MQ refers to a message broker service used for providing compatibility with many popular message brokers. This service is best for migrating applications from existing message brokers depending on compatibility with APIs like JMS or protocols.

What are the features of Amazin SQS?

This service consists of unique features. Some of them include:

1. Queue types

Amazon SQS provides two queue types for different application requirements:

1. Standard Queues

Standard queues support an unlimited number of transactions per second (TPS) per API action. In this, the message is delivered at least once. However, but, occasionally more than one copy of a message is delivered. The message delivered occasionally must be in an order different from which they were sent.

Further, you can use standard message queues in scenarios like:

  • Firstly, decoupling live user requests from intensive background work.
  • Secondly, allocating tasks to multiple worker nodes. Thus, processing a large number of credit card validation requests.
  • Lastly, batching messages for future processing. Scheduling multiple entries to add to a database.

2. FIFO Queues

FIFO queues have the support of up to 300 messages per second. However, when there is batching of 10 messages per operation then, FIFO queues can support up to 3,000 messages per second. Further, if there is a need for higher throughput, you can enable high throughput mode for FIFO on the Amazon SQS console, which will support up to 30,000 messages per second with batching. In this, the message is delivered once and it remains accessible until a consumer process and deletes it. The receiving order of messages sent and received is First-In-First-Out.

Further, FIFO queues are created for enhancing messaging between applications when the order of operations and events is critical, or where duplicates are not allowed. For example:

  • Firstly, ensuring that user-entered commands are executed in the right order.
  • Secondly, displaying the correct product price by sending price modifications in the right order.
  • Lastly, preventing a student from enrolling in a course before registering for an account.
2. Functionality

1. Unlimited queues and messages

Creating unlimited Amazon SQS queues with an unlimited number of messages in any region.

2. Payload Size

Message payloads can have up to 256KB of text in any format. In this, every 64KB ‘chunk’ of the payload is billed as 1 request.

3. Batches

Sending, receiving, or deleting messages in batches of up to 10 messages or 256KB. However, the batches cost the same amount as single messages.

4. Long polling

Reduce irrelevant polling for minimizing cost while receiving new messages as quickly as possible. However, when the queue is empty, then, long-poll requests wait up to 20 seconds for the next message to arrive. 

5. Message locking

After receiving a message, it becomes “locked” while being processed. This is for keeping other computers from processing the message simultaneously. However, if the message processing fails, then, the lock will expire and the message will be available again.

6. Queue sharing

Securely sharing Amazon SQS queues anonymously or with specific AWS accounts. Queue sharing can also restrict by IP address and time of day.

7. Dead Letter Queues (DLQ)

Dead Letter Queues is for handling messages that have not been successfully processed by a consumer. However, when the maximum receive count exceeds a message then, it moves to the DLQ associated with the original queue. 

3. Using Amazon SQS with other AWS infrastructure web services

Amazon SQS message queuing can be used with other AWS services like Redshift, DynamoDB, RDS, EC2, ECS, Lambda, and S3 for making distributed applications more scalable and reliable. However, some common design patterns include:

  • Firstly, Work Queues. This is for decoupling components of a distributed application that may not all process the same amount of work simultaneously.
  • Secondly, Buffer and Batch Operations. This is for adding scalability and reliability for architecture and level out temporary volume spikes without losing messages or increasing latency.
  • Thirdly, Request Offloading. Moving slow operations off of interactive request paths by enqueuing the request.
  • Next, Fanout. Combining SQS with Simple Notification Service (SNS) for sending identical copies of a message to multiple queues in parallel.
  • Then, Priority. Using separate queues for providing prioritization of work.
  • After that, Scalability. In SQS, message queues decouple processes, so it is easy for scaling up the sending or receiving rate of messages.
  • Lastly, Resiliency. Message queues decouple components of your system, so if a process reading messages fails, then, messages can still add to the queue for processing when the system recovers.

After understanding the basic overview, features, and benefits of Amazon SQS, now, in the next section, we will learn about the process of managing the ques using the SQS console.

Getting started with Amazon SQS

The best way to start Amazon SQS journey is to understand the process of managing queues and messages using the Amazon SQS console.

Step 1: Creating a queue

In this step, we will learn how to create and configure a FIFO queue.

  • Firstly, open the Amazon SQS console.
  • Secondly, choose Create queue.
  • Thirdly, specify the correct region on the Create queue page.
  • Then, by default, the Standard queue type is selected. Now, choose FIFO.
    • However, remember that you cannot change the queue type after creating a queue.
  • Next, enter a Name for your queue. The name of a FIFO queue must end with the .fifo suffix.
  • Lastly, for creating a queue with the default parameters, scroll to the bottom and select Create Queue. Then, Amazon SQS creates the queue and shows the queue’s Details page.
    • The new queue information propagates across the system by Amazon SQS. This is because Amazon SQS is a distributed system and there is a slight delay before the queue is displayed on the Queues page.
solution architect associate
Step 2: Sending a message

You can send a message after creating a queue.

  • Firstly, choose Queues from the left navigation pane. Then, select the queue that you created from the queue list.
  • Secondly, select Send and receive messages from Actions.
    • Here, the console shows the Send and receive messages page.
  • Thirdly, enter text in the Message body
  • After that, enter a Message group id for the queue. 
  • Then, enter a Message deduplication id.
  • Lastly, select Send the message.
    • Now, the message is sent and the console shows a success message. Select details for displaying information about the sent message.
Step 3: Receiving and deleting your message

After sending a message to a queue, you can retrieve the message from the queue. However, when you request messages from a queue, you cannot specify which message to retrieve. Instead, you have to specify the maximum number of messages you want to retrieve.

  • Firstly, select a queue from the Queues page.
  • Secondly, select Send and receive messages from Queue Actions.
    • Here, the console shows the Send and receive messages page.
  • Now, select Poll for messages.
    • Here, the Amazon SQS begins to poll servers for finding the messages in the queue. The progress bar on the right side of the Receive messages section shows the polling duration.
  • Then, the Messages section shows the list of the received messages. For every message, the list displays the message ID, sent date, size, and receive count.
  • After that, for deleting messages, select the messages that you want to delete and then choose Delete.
  • Lastly, select delete in the Delete Messages dialog box.
Step 4: Deleting your queue
  • Firstly, select the queue that you have created from the queue list.
  • Secondly, select the queue to delete from the Queues page.
  • Then, select Delete queue. Now, the console shows the Delete queue dialog box.
  • Next, confirm the deletion by entering delete in the Delete queue dialog box.
  • Lastly, select Delete.
aws professional

Amazon SQS pricing

Amazon SQS pricing includes:

  • Firstly, you only pay for the service you use
  • Secondly, no minimum fee
  • Lastly, use AWS Pricing Calculator for estimating your monthly bill
Amazon Simple Queue Service (SQS) pricing
Image Source: AWS

Final Words

Amazon Simple Queue Service (SQS) has proved to be useful for providing services to many organizations including the top names like NASA, BMW, and redBus. With having the ability to decoupling and scaling microservices, and serverless applications, SQS is capable of removing the complexity thus, empowering developers to focus on differentiating work. With the above information, learn about the features of Amazon SQS and start by creating a queue using the SQS console with help of the documentation.

Menu