Amazon SQS (Simple Queue Service) is a hosted queue solution from AWS which helps you in creating distributed software systems. The hosted queues are highly available, durable and secure. There are two types of SQS services offered by AWS and they are:
Amazon SQS - Standard Queue
This is the default queue type provided by Amazon SQS. This ensures at-least-once message delivery. This means the message will be delivered at least once to the queue. There is a possibility that you can receive the same message more than once during the processing. This is due to the highly distributed architecture and can provide high throughput. Some of the key features are:
- High Throughput - It supports a nearly unlimited number of API calls per second per method.
- A message is delivered at least once.
- Best Effort Ordering - It means messages are generally delivered in the same order as they entered in the SQS.
Some of the use cases for the Amazon SQS - Standard Queue are:
- Creating batch for future processing of the messages.
- De-couple live user request from the backend processing required to enrich the data stored. Like after-effects of data saved in a database.
- Horizontally scale the number of processes to complete a task. Like process high number of rows using messages and distributed nodes consuming the messages.
Amazon SQS - FIFO Queue
Amazon SQS - FIFO queue stands for First In First Out Queue. The queue is designed to ensure the order of the messages. The first message published to the SQS will be the first message consumed by the consumer. Unlike the standard SQS, the FIFO SQS does have some limitations of its own in terms of throughput. Some of the key features of FIFO SQS are:
- High Throughput - The throughput in FIFO SQS depends on the way you use it to process the messages. In the case of batch processing, FIFO SQS supports 3000 messages per second per API method. The calculation is based on the batch size of 10. In the case of the non-batch processing, it supports 300 API calls per second per method.
- A message is delivered to be processed exactly once. In case the message is not processed, it will remain in the SQS. The duplicate messages will not be included in the SQS in the first place.
- First In Forst Out Delivery - As described by the name, the messages are delivered in the order of them being received by the SQS in the first place.
Some of the use cases for Amazon SQS - FIFO Queue are:
- They are helpful in recording transactions like price actions or other stuff which require an order to be followed.
- They help in maintaining the order of processing where it is required.
Benefits of Amazon SQS
- Availability: Amazon SQS has high availability because of the use of the highly redundant infrastructure.
- Scalability: Amazon SQS can process and scale easily with the increase in the high demand in the usage of the SQS.
- Security: Amazon SQS supports encryption of messages during the transmission of messages to the SQS. Amazon KMS (Key Management Service) can be utilised to perform server-side encryption.
- Durability: Amazon SQS stores each message on multiple servers and have a high redundancy.
- Reliability: Amazon SQS locks the messages while your consumer processes the message. This is to make sure the messages are not picked up or processed by more than one consumer.