Simple Queue Service (SQS)
Welcome to CloudAffaire and this is Debjeet.
In this blog post, we will start with a new AWS service SQS or Simple Queue Service.
What is queue?
In computer science, a queue is a collection in which the entities in the collection are kept in order and the principal (or only) operations on the collection are the addition of entities to the rear terminal position, known as enqueue, and removal of entities from the front terminal position, known as dequeue. This makes the queue a First-In-First-Out (FIFO) data structure. In a FIFO data structure, the first element added to the queue will be the first one to be removed. This is equivalent to the requirement that once a new element is added, all elements that were added before have to be removed before the new element can be removed. Often a peek or front operation is also entered, returning the value of the front element without dequeuing it. A queue is an example of a linear data structure, or more abstractly a sequential collection.
Queues provide services in computer science, transport, and operations research where various entities such as data, objects, persons, or events are stored and held to be processed later. In these contexts, the queue performs the function of a buffer.
Queues are common in computer programs, where they are implemented as data structures coupled with access routines, as an abstract data structure or in object-oriented languages as classes. Common implementations are circular buffers and linked lists.
Simple Queue Service:
AWS SQS or Simple Queue Service is one of the oldest services that was introduced to the general public. AWS Simple Queue Service (SQS) is a fully managed message queuing service that enables you to decouple and scale microservices, distributed systems, and serverless applications. SQS eliminates the complexity and overhead associated with managing and operating message oriented middleware and empowers developers to focus on differentiating work. Using SQS, you can send, store, and receive messages between software components at any volume, without losing messages or requiring other services to be available.
SQS queue types:
SQS provides two types of queue namely standard and FIFO (First In First Out).
- Supports a nearly unlimited number of transactions per second (TPS) per API action.
- A message is delivered at least once, but occasionally more than one copy of a message is delivered.
- Occasionally, messages might be delivered in an order different from which they were sent.
- Used when throughput is more important than the order of the message.
- Support up to 300 messages per second, per API action without batching and 3000 messages per second, per API action with batching.
- A message is delivered once and remains available until a consumer processes and deletes it. Duplicates aren’t introduced into the queue.
- The order in which messages are sent and received is strictly preserved (follows FIFO principle)
- Used when order is more important than the throughput of the message.
SQS Queue attributes:
- Default Visibility Timeout(between 0 seconds and 12 hours): Default Visibility Timeout The length of time (in seconds) that a message received from a queue will be invisible to other receiving components.
- Message Retention Period(between 1 minute and 14 days): The amount of time that Amazon SQS will retain a message if it does not get deleted.
- Maximum Message Size(between 1 and 256 KB): Maximum message size (in bytes) accepted by Amazon SQS.
- Delivery Delay(between 0 seconds and 15 minutes): The amount of time to delay the first delivery of all messages added to this queue.
- Receive Message Wait Time(between 0 and 20 seconds): The maximum amount of time that a long polling receive call will wait for a message to become available before returning an empty response.
- Dead Letter Queue (enable or disable): A dead letter queue is used by other queues (source queue) for messages that can’t be processed (consumed) successfully.
- Encryption (enable or disable): Encrypt messages stored in both Standard and FIFO queues using an encryption key provided by AWS Key Management Service (KMS).
Hope you have enjoyed this article. In the next blog post, we will create our 1st SQS queue.
To get more details on AWS SQS, please refer below AWS documentation