What is SQS - Steps to Configure SQS Queue
subbu.png Subbusainath Rengasamy
8 min read Aug 19, 2021
aws
sns
sqs

What is SQS - Steps to Configure SQS Queue

aws
sns
sqs

Designing a distributed architecture can get complicated. One of the pain points is to address the data flow between multiple systems.

Luckily, cloud providers like AWS have plenty of services that aid in solving this issue. We could use services like Amazon SNS, Amazon SQS, AWS Step Functions, Amazon Event Bridge, AWS Lambda, and triggers from services like Amazon S3, Amazon DynamoDB, etc. Having many choices leads to confusion in the selection of services for the application.

In this blog, we will be focusing on Amazon SQS and when to use it.

What is SQS?

Amazon Simple Queuing Service, a.k.a Amazon SQS, is a message queuing service that helps us (Developers) store, send and receive a message from one component to another without any loss of transmission. It is the first infrastructure service for public usage from AWS.

SQS helps us decouple the components and build distributed applications without dealing with the complexity of creating and maintaining the message queues. SQS asynchronously processes the messages. If one party requests a particular message and those messages will be in a queue once it gets ready, the following part processes them in a ready state.

Two Types of Queuing by SQS

SQS supports two types of queuing methods. Standard Queue and FIFO (First In, First Out) Queue.

1. Standard Queue

The standard queue is a default queuing method used by SQS. With this method, SQS makes sure that the message is delivered at least once. It tries to preserve that messages from queues will be processed in the same order as received.

For instance, you are ordering food in the restaurant, and the waiter brings you food at least one as in order and the rest of them based on the availability of food’s preparation status.

2. FiFO (First in, First out)

FIFO queue method ensures that messages are delivered exactly once and maintains the order of sent and received messages. It avoids duplication of messages when processed.

For instance, in the bank, you get your token from the machine and wait for your token number to be called from one of the counters. Once the banker has called your number, you will get your service done by the banker. Like this scenario, consider a process of sending a message to check your loan balance. Your token number will be your message ID, and once your message queue is ready, i.e., your token number has been called by the banker, the banker will process your service, i.e., a message will be processed to the destination.

What happens if the destination endpoint doesn’t receive its data (message)? and How SQS solve this issue?

SQS can help you deal with the problem by placing or storing the failed-to-process message in a “Dead-Letter Queue.” Dead Letter Queue helps the SQS to debug failed messages by isolating the issue. SQS has this redrive policy that specifies the source queue, the dead-letter queue, and the conditions under which notifications should be sent or received.

If the source queue’s consumer fails to read the message and the retries exceed a maximum received count for a queue, then SQS moves the message into the dead letter queue.

The main point of using Dead Letter Queue in SQS is to handle message failure easily!

dead-letter-queue.png

Ref: Amazon SQS dead-letter queues

What is visibility timeout? How does it help SQS to solve its problems?

Visibility Timeout is a specified period that can be used to determine the visibility of a message in a queue that should be processed.

In SQS, visibility timeout is set to prevent other consumers from receiving and processing the queue message.

sqs-visibility-timeout-diagram.png

Once the consumer of the source queue receives the message from the queue, the visibility timeout will start. By default, the visibility timeout is set to 30 seconds for SQS to process the message and delete it after it finishes its duty. This process is to avoid other consumers seeing the same message again in the queue.

We can change these time settings. The minimum time is 0 seconds, and the maximum time is 12 hours.

When to Use SQS ?

Let us consider a scenario: You created an E-Commerce site that sells Electrical items to customers online. Apart from your website, you can send an email update about the product delivery status. Every product from your website might have unique IDs, which help you track the process.

For this process, you can use Amazon Simple Queuing Service. Using the service, you can communicate to your distributed services that maintain procedures like shipment, order packing, etc, which are all in sequential order in an e-commerce transaction. SQS gives you freedom over communication between different services which are connected in a distributed manner.

Steps to Create SQS Queue using AWS Console

Step 1

Head to Simple Queue Service and click on “Create queue” and select “Standard” queue option for SQS Standard queue enter your queue’s name.

create_queue.png

Step 2

Under the Configuration section, You can set the visibility timeout, Message retention period, Delivery delay, Maximum message size, and Receive message wait time for your SQS queue. In my case, we want to keep my visibility timeout as 60 seconds and keep other options as default.

Configuration_sqs.png

Step 3

Under the Access policy section, we can set who can access this queue and the actions allowed in the queue. You can configure basic and advanced settings for the queue. For the basic settings, You can define who can send messages to the queue and determine who can receive messages to the queue. Here we will select Basic Access Policy and keep only the Queue Owner to send and receive messages from the queue. You can see JSON also on the right side for your reference.

Access_policy.png

Step 4

Under the Encryption section (Optional), we can set encryption for the messages that are all sent from the queue by enabling the server-side encryption option. But for the demo purpose, we’ll select “Disable” and proceed further.

Encryption.png

Step 5

Now you can click “Create queue”. And your SQS Queue is ready to use.

step 6

Now you can use your created demo queue by configuring it with the lambda function trigger. Under the Lambda Triggers section, click on the “Configure Lambda function” and select your lambda function from the drop-down list

configure_lambda_trigger.png

We have created a sample Lambda function trigger for this SQS queue.

lambda_trigger.png

Step 7

Under the Dead-letter-queue section(Optional), we can set dead-letter queues for our messages in the queue. By default, we’ll select Enable and choose queue ARN from the drop-down and enter the maximum receives to the dead letter queue. But, we can create DeadLetterQueue once we create our queue first. After creating our SQS Queue, Under the Dead-letter-queue section, we can add our DeadLetterQueue and click on the “Save” button.

DLQ.png

Pricing

  • You Pay for what you use
  • No minimum fee
  • First 1 Million Requests/Month be free for both standard and FIFO queue
  • From 1 Million to 100 Billion Requests/Month $0.40 for standard and $0.50 for FIFO queue.
  • From 100 Billion to 200 Billion Requests/Month $0.30 for standard and $0.40 for FIFO queue.
  • Over 200 Billion Requests/Month $0.24 for standard and $0.35 for FIFO queue.

Very Minimal pricing and Pay for what you use - simple as that. We’ll cover the rest in the coming parts of this series. Stay tuned.

Ref: For Knowing about extreme depth of SQS service

FAQs

1. How does Amazon SQS differ from Amazon SNS?

SQS is a pull-based queuing system where consumers poll for messages, whereas SNS is a push-based pub/sub model that delivers messages to multiple subscribers simultaneously. If your architecture requires broadcast to multiple endpoints (like Lambda, HTTP/S, or SQS), SNS is often layered with SQS to enable fan-out patterns with durability and decoupling.

2. Can SQS help during peak traffic or flash sales?

Absolutely. When demand spikes, like a Black Friday sale or a trending campaign, SQS acts as a buffer. It absorbs the rush, queues the requests, and lets your systems breathe. You won’t lose orders, crash services, or overload your operations team trying to recover.

3. How does SQS reduce the risk of failure in my customer experience?

By introducing separation. When one part of your system fails, the rest can continue running. Orders can still be placed even if the shipping service is momentarily down. SQS holds the message until the system is back, ensuring continuity without apologies.

Application Modernization Icon

Innovate faster, and go farther with serverless-native application development. Explore limitless possibilities with AntStack's serverless solutions. Empowering your business to achieve your most audacious goals.

Talk to us

Author(s)

Tags

Your Digital Journey deserves a great story.

Build one with us.

Recommended Blogs

Cookies Icon

These cookies are used to collect information about how you interact with this website and allow us to remember you. We use this information to improve and customize your browsing experience, as well as for analytics.

If you decline, your information won’t be tracked when you visit this website. A single cookie will be used in your browser to remember your preference.