What is a SQS?

Amazon SQS is a distributed queue web service that gives you access to a message queue that can be used to store messages while waiting for a computer to process them.

Using SQS, you can decouple the components of an application so they run independently, easing message management between components.
Messages can contain up to 256KB of text in any format and if you want to store more text in a message, the text will be stored in S3.
Any component can later retrieve the messages programmatically using the Amazon SQS API
SQS is pull-based not pushed-based
The queue acts as a buffer between the component producing and saving data, and the component receiving the data for processing.
This means the queue resolves issues that arise if the producer is producing work faster than the consumer can process it, or if the producer or consumer are only intermittently connected to the network.
Messages can be kept in the queue from 1 minute to 14 days; the default retention period is 4 days
Visibility timeout is the amount of time that the message is invisible in the SQS queue after a reader picks up the message.
Provided the job is processed before the Visibility timeout expires, the message will then be deleted from the queue.
If the job is not processed within that time, the message will become visible again and another reader will process it.
This could result in the same message being delivered twice.
Visibility max timeout is 12 hours.
Amazon SQS long polling is a way to retrieve messages from your SQS queues.
While the regular short polling returns immediately, long polling doesn't return a response until a message arrives in the message queue, or the long poll times out.
SQS uses multiple hosts, and each host holds only a portion of all the messages.
There are two types of queues: Standard queues and FIFO queues

Amazon MQ

Amazon MQ, Amazon SQS, and Amazon SNS are messaging services that are suitable for anyone from startups to enterprises.
If you're using messaging with existing applications and want to move your messaging service to the cloud quickly and easily, it is recommended that you consider Amazon MQ.
It supports industry-standard APIs and protocols so you can switch from any standards-based message broker to Amazon MQ without rewriting the messaging code in your applications.

Messages Life Cycle

Always remember that the messages in the SQS queue will continue to exist even after a EC2 instance has processed it, until you delete that message.
You have to ensure that you delete the message after processing to prevent the message from being received and processed again once the visibility timeout expires.

There are three main parts in a distributed messaging system:
1. The components of your distributed system (EC2 instances)
2. Your queue (distributed on Amazon SQS servers)
3. Messages in the queue.

You can set up a system which has several components that send messages to the queue and receive messages from the queue.
The queue redundantly stores the messages across multiple Amazon SQS servers.

Standard queues (default)

A standard queue lets you have a nearly-unlimited number or transactions per second.
Standard queues quarantee that a message is delivered at least once.
Occasionally more than one copy of a message might be delivered out of order.
However, standard queues provide best-effort ordering which ensures that messages are generally delivered in the same order as they are sent.

FIFO queues (first in first out)

The most important features of this queue type are first in first out delivery and exactly-once processing:
The order in which messages are sent and received is strictly preserved and a message is delivered once and remains available until a consumer processes and deletes it; duplicates are not introduces into the queue.

FIFO queues also support message groups that allow multiple ordered message groups within a single queue.
FIFO queues are limited to 300 transactions per second (TPS), but have all the capabilities of standard queues.