AWS SQS: What, why, when?

AWS SQS: What, why, when?

Everything to know about Amazon Simple Queue Service (SQS)…

AWS or Amazon Web Services is a cloud service provider that helps business to run their digital infrastructure. It provides various services to solve complex challenges. One of these services is the Simple Queue Service (SQS).

What is SQS?

Simple Queue Service is a distributed messaging queue that helps in solving producer-consumer connectivity for distributed systems. SQS enables your services to send and store messages to a queue at any volume without losing messages even if the consumer is down.

Messaging queue is a technique of sending context about a process between services in a web application.

SQS is a messaging queue service that helps you decouple your services and improve their scalability and reliability. By using SQS, you can run background tasks asynchronously, which means that they can be processed independently of the main flow of your application.

Why SQS?

SQS reduces the overhead of you managing a distributed messaging queue to send, store, and receive messages between services in a distributed web application.

Features of SQS:

Here are some of the features of SQS:

  1. At least Once Delivery: This means a message once sent into the queue will be consumed at least once. In a standard queue, there can be duplicates and in FIFO it will be consumed exactly once no duplicates are allowed.

  2. Resiliency: When a consumer fails it does not impact the queue. Since it is decoupled all the messages that are in the queue will remain and can be processed once the service is up again.

  3. Message Locking: When a message is being consumed it becomes unavailable to other consumers. If the message fails the message will again become visible. This is part of the visibility timeout.

  4. Unlimited messages: There are no limits on the number of messages you can send in the queue. So in case, there is a spike in requests the queue will handle the spike just fine.

  5. Batches: We Can send 10 messages at a time with no extra cost.

  6. Secure: Secured by AWS IAM (identity and access management) and uses HTTPS and TLS.

  7. reliability: Queue is stored in a single AWS Region with multiple redundant Availability zones (AZ). So, if a single region is affected it does not make messages unavailable.

Types Of SQS Queues:

There are two different types of queues that AWS provides:

  • Standard Queue: This can be used in many scenarios as long as you are okay with more than one delivery or out-of-order message.
    Messages in the queue are not ordered. This means messages sent in one order might not be received in the same order.
    Support an unlimited number of messages/transactions per second (TPS).
    Messages might get duplicated to ensure at least once delivery.

  • FIFO (First In First Out): FIFO is used for scenarios where either or both the order of event and duplicate message can not be tolerated.
    Messages in the queue maintain the Order in which the message is being pushed to the queue.
    This can support a max of 30,000 messages with batch and 3,000 without batching.
    Messages are never duplicated in this queue.

Functionalities of SQS:

SQS has different functionality here are some:

  • Delay Queue: You can specify a delay of up to 15 minutes for the queue or message. This will make messages pushed to the queue invisible to consumers till the specified delay time. This helps when you want the producer to do some processing before the consumer consumes the message.

  • Visibility Timeout: Once a message is received by the consumer the queue will lock the message till a certain time period from other consumers. The queue will wait for the consumer to either send an acknowledgment of completion to delete the message from the queue. Or send a failed event or skip acknowledgment to retry the message again after the timeout expires.
    The default window is 30 seconds and the max is 12 hours.

  • Dead Letter Queue: A queue has a retry config that tells about how many times a message in the queue will be retried. But once the retry window is over we need to debug the root cause of the failure and retry the message again. To do that we can configure a queue with a retry policy to send messages that have failed even after retry. This can help when the consumer is facing some client dependency failures.

When to use SQS?

SQS (Simple Queue Service) offers many benefits, including the ability to decouple and scale microservices, applications, and servers, as well as the ability to reliably transmit any volume of data. However, it is important to carefully consider the pros and cons of using SQS and whether it is the best fit for your specific needs. Here are some scenarios where SQS may be particularly useful for web applications:

  1. Asynchronous processing: SQS allows you to offload time-consuming tasks, such as image or video processing, to separate worker systems, which can then process the tasks in parallel. This allows your web application to respond to requests more quickly, as it does not have to wait for the task to complete before returning a response.

  2. Load balancing: SQS can help distribute workloads evenly across multiple systems, which can improve the scalability and reliability of your web application.

  3. Decoupling: SQS can be used to decouple different components of your web application, allowing them to operate independently and asynchronously. This can make your application more resilient to failures and easier to modify or update.

  4. Event-driven architecture: SQS can be used to trigger events or actions in response to specific events, such as the creation or deletion of a database record. This can allow you to build more flexible, responsive web applications.

Overall, SQS can be a powerful tool for web developers, but it is important to carefully evaluate its suitability for your specific needs and use case.

AWS SQS Customers:

SQS is used by companies around the world to build and operate distributed systems, applications, and services. Some notable examples of companies that use AWS SQS include:

  • Amazon: The world’s largest online retailer, Amazon uses SQS to power its e-commerce platform and manage the flow of data between its various systems and services.

  • Lyft: The ride-hailing company uses SQS for its dispatch and billing systems.

  • Cred: The fintech company uses SQS to manage the flow of data between its mobile app and its backend systems, including its payment processing and customer relationship management systems.

  • Razorpay: The Indian payment gateway company uses SQS for its payment processing systems and its various business partners.

  • Medium: The online publishing platform uses SQS for its content management and analytics systems.

  • OYO: The Online hotel booking platform uses SQS for its booking and reservation systems.

  • Intuit: The financial software company uses SQS for its accounting and tax preparation software.

  • Quora: The question-and-answer platform uses SQS for its search and recommendation algorithms.

  • Accenture: The global professional services company uses SQS for its project management and collaboration tools.

These are just a few examples of the many companies that use AWS SQS to build and operate distributed systems, applications, and services.

That’s a small brief about AWS SQS. Send us your feedback using the message button below. Your feedback helps us create better content for you and others. Thanks for reading!

If you like the article please like and share. To show your support!
Thanks.

Did you find this article valuable?

Support Ayush Singhal by becoming a sponsor. Any amount is appreciated!