Amazon Simple Queue Service Documentation
Amazon Simple Queue Service (SQS) is a managed message queuing service that enables you to decouple and scale microservices, distributed systems, and serverless applications. SQS reduces the complexity of managing and operating message-oriented middleware. SQS is designed so that you can send, store, and receive messages between software components at any volume, without losing messages or requiring other services to be available.
Queue Types
Standard queues: Standard queues are designed to support a nearly unlimited number of transactions per second (TPS) per API action. They are also designed to provide “At-Least-Once Delivery,” which means a message is delivered at least once, but occasionally more than one copy of a message is delivered. Standard queues are also designed to offer “Best-Effort Ordering,” which means that occasionally, messages might be delivered in an order different from which they were sent. You can use standard message queues in many scenarios, as long as your application can process messages that arrive more than once and out of order, for example.
- Decouple live user requests from intensive background work: Let users upload media while resizing or encoding it.
- Allocate tasks to multiple worker nodes: Process a high number of credit card validation requests.
- Batch messages for future processing: Schedule multiple entries to be added to a database.
FIFO queues: You can batch messages per operation to multiply the number of messages a FIFO queues can support per second. If you require higher throughput, you may be able to enable high throughput mode for FIFO on the Amazon SQS console, which is designed to support an increased number of messages per second with or without batching. FIFO queues are designed to offer “Exactly-Once Processing,” which means that a message is delivered once and remains available until a consumer processes and deletes it, which helps to prevent duplicates in the queue. FIFO queues are also designed to provide “First-In-First-Out Delivery,” which means the order in which messages are sent and received is strictly preserved (i.e., First-In-First-Out). FIFO queues are designed to enhance messaging between applications when the order of operations and events is critical, or where duplicates can't be tolerated, for example:
- Ensure that user-entered commands are executed in the right order.
- Display the correct product price by sending price modifications in the right order.
- Prevent a student from enrolling in a course before registering for an account.
Functionality
- Nearly unlimited queues and messages: Create nearly unlimited Amazon SQS queues with a nearly unlimited number of messages in any Region where Amazon SQS is available.
- Payload Size: Message payloads may be broken into smaller ‘chunks’ that are each billed as 1 request. For example, a single API call with a 256KB payload will be billed as four separate 64BK requests. To send larger messages, you can use the Amazon SQS Extended Client Library for Java, which uses Amazon Simple Storage Service (S3) to store the message payload. A reference to the message payload is sent using SQS.
- Batches: Send, receive, or delete messages in batches. Batches cost the same amount as single messages, meaning SQS can be even more cost effective for customers that use batches.
- Long polling: Reduce extraneous polling to minimize cost while receiving new messages as quickly as possible. When your queue is empty, long-poll requests wait for a certain amount of time for the next message to arrive. Long-poll requests cost the same as regular requests.
- Send and read messages simultaneously.
- Message locking: When a message is received, it becomes “locked” while being processed. This is designed to keep other computers from processing the message simultaneously. If the message processing fails, the lock will expire and the message will be available again.
- Queue sharing: Amazon SQS queues are designed to be shared anonymously or with specific AWS accounts. Queue sharing can also be restricted by IP address and time-of-day.
- Server-side encryption (SSE): Protect the contents of messages in Amazon SQS queues using keys managed in the AWS Key Management Service (AWS KMS). SSE is designed to encrypt messages as soon as Amazon SQS receives them. The messages are stored in encrypted form and Amazon SQS decrypts messages only when they are sent to an authorized consumer.
- Dead Letter Queues (DLQ): Handle messages that a consumer has not successfully processed with dead-letter queues (DLQs). When a message’s maximum receive count is exceeded, Amazon SQS moves the message to the DLQ associated with the original queue. DLQs must be of the same type as the source queue (standard or FIFO). You can inspect the messages in DLQs to understand why your consumer has not successfully received them. Once you have remediated the issues, you can move the messages from the DLQ to their respective source queues.
Additional Information
For additional information about service controls, security features and functionalities, including, as applicable, information about storing, retrieving, modifying, restricting, and deleting data, please see https://docs.aws.amazon.com/index.html. This additional information does not form part of the Documentation for purposes of the AWS Customer Agreement available at http://aws.amazon.com/agreement, or other agreement between you and AWS governing your use of AWS’s services.