Original article was published by Praful Dhabekar on Artificial Intelligence on Medium
AWS SQS(Simple Queue Service): Pros & Cons
Queues are a powerful way of combining software architecture. They allow for asynchronous communication between different systems. Amazon provides Amazon SQS (Simple Queue Service) with its version of queues.
What is Amazon SQS?
Amazon Simple Queue Service (SQS) is offered by Amazon Web Services ( AWS) as a managed message queue service. It provides an HTTP API through which items can be submitted to and readout of a queue by apps. AWS fully manages the queue itself, making SQS an easy solution for passing messages between different components of software systems running in the cloud.
How does SQS work?
SQS provides a message-submitting API endpoint and another endpoint to read messages from a queue. Each message can only be retrieved once, and at the same time, you can have many customers submit messages and read messages from a queue.
Unformatted strings, XML, or JSON may be the messages that SQS manages. Since SQS guarantees delivery exactly once, and since you can send messages to and read messages from a given queue simultaneously, SQS is a good choice for integrating multiple independent systems.
You might well be asking: if you can provide an internal HTTP API for might service, why use SQS? Although HTTP APIs are an easy way to connect external users to software systems, when it comes to strictly internal systems integration, they are not the most powerful tool. A message queue is a lighter one. SQS also manages items such as automatic retries, maintaining queue status in AWS across various availability zones, and keeping track of expiry timeouts on all messages, in particular.
Pay for what you use
You only get charged for the messages you read and write when using SQS. There are no recurring or base charges.
Ease of setup
Since SQS is a managed service, no infrastructure needs to be set up to start using SQS. To read and write messages, you may simply use the API, or use the SQS & Lambda integration.
Options for Standard and FIFO queues
You can choose between a regular queue and a FIFO queue out of the box when building an SQS queue. For various purposes, both of these queue forms may be useful.
Size the SQS queues to the number of messages you write and read. You don’t need to scale the queues; AWS takes care of all of the scaling and performance-at-scale aspects.
Automatic deduplication for FIFO queues
When using queues, deduplication is necessary, and SQS will do the job of removing any duplicate messages for you for FIFO queues. This makes SQS FIFO queues ideal for tasks where it is necessary to have each task performed exactly once.
A separate queue for unprocessed messages
For debugging, this feature of SQS is useful. All messages that can not be processed are sent to a “dead-letter” queue where they can be checked. This queue has allowed all the normal integrations, so you can subscribe to it using, for example, an AWS Lambda event to send a notification when it is not possible to process an object.
Reduced control over performance
What you can well end up having to do when running a message queue system on a scale is to fine-tune its output to fit your needs. This is not a choice with SQS: the service is fully controlled, and you don’t have to look under the hood.
High cost at scale
With pay per use pricing, your SQS bill can be very large if the amount of messages you send is quite high. Data transfer charges are part of SQS pricing, and these can add up if you send large messages, or if you process messages from outside the main AWS area where the queue is located. In certain cases, the cost of using SQS may be higher than the cost of operating your own queue system while running on a scale of millions of messages handled every day, even with the overhead for maintaining your own solution.
Lack of support for broadcast messages
SQS does not accept a way for multiple organizations to retrieve the same message with its “exactly once” transmission, making SQS not so effective for one-to-many broadcasts. To address this, developers can use SQS alongside SNS in cases where one-to-many delivery is necessary.
AWS SQS is undoubtedly powerful but you can get more benefits if you combine with Amazon SNS (a distributed publish-subscribe system) and AWS Lambda (serverless computing platform) functions perfectly well with it.
👋 Join FAUN today and receive similar stories each week in your inbox! ️ Get your weekly dose of the must-read tech stories, news, and tutorials.