| Did this page help you? Yes No Tell us about it... |
This introduction to Amazon SQS is intended to give you a high-level overview of this web service. After reading this section, you should understand the basics you need to work through the examples in this guide.
Amazon SQS is a distributed queue system that enables web service applications to quickly and reliably queue messages that one component in the application generates to be consumed by another component. A queue is a temporary repository for messages that are awaiting processing.
Using Amazon SQS, you can decouple the components of an application so they run independently, with Amazon SQS easing message management between components. Any component of a distributed application can store messages in a fail-safe queue. Messages can contain up to 64 KiB of text in any format. Any component can later retrieve the messages programmatically using the SQS API.
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.
SQS ensures delivery of each message at least once, and supports multiple readers and writers interacting with the same queue. A single queue can be used simultaneously by many distributed application components, with no need for those components to coordinate with each other to share the queue.
Amazon SQS is engineered to always be available and deliver messages. One of the resulting tradeoffs is that SQS does not guarantee first in, first out delivery of messages. For many distributed applications, each message can stand on its own, and as long as all messages are delivered, the order is not important. If your system requires that order be preserved, you can place sequencing information in each message, so that you can reorder the messages when the queue returns them.
Amazon SQS provides the following major features:
Redundant infrastructure—Guarantees delivery of your messages at least once, highly concurrent access to messages, and high availability for sending and retrieving messages
Multiple writers and readers—Multiple parts of your system can send or receive messages at the same time
SQS locks the message during processing, keeping other parts of your system from processing the message simultaneously.
Configurable settings per queue—All of your queues don't have to be exactly alike
For example, one queue can be optimized for messages that require a longer processing time than others.
Variable message size—Your messages can be up to 65536 bytes (64 KiB) in size
For even larger messages, you can store the contents of the message using the Amazon Simple Storage Service (Amazon S3) or Amazon SimpleDB and use Amazon SQS to hold a pointer to the Amazon S3 or Amazon SDB object. Alternately, you can split the larger message into smaller ones.
For more information about the services, go to the Amazon S3 detail page and the Amazon SimpleDB detail page.
Access control—You can control who can send messages to a queue, and who can receive messages from a queue
Delay Queues—A delay queue is one which the user sets a default delay on a queue such that delivery of all messages enqueued will be postponed for that duration of time. You can set the delay value when you create a queue with CreateQueue, and you can update the value with SetQueueAttributes. If you update the value, the new value
affects only messages enqueued after the update.
The following diagram and process describe the lifecycle of an Amazon SQS message, called Message A, from creation to deletion. Assume that a queue already exists.

Message Lifecycle
![]() | Component 1 sends Message A to a queue and the message is redundantly distributed across the SQS servers. |
![]() | When Component 2 is ready to process a message, it retrieves messages from the queue, and Message A is returned. While Message A is being processed, it remains in the queue and is not returned to subsequent receive requests for the duration of the visibility timeout. |
![]() | Component 2 deletes Message A from the queue to avoid the message being received and processed again once the visibility timeout expires. |
![]() | Note |
|---|---|
SQS automatically deletes messages that have been in a queue for more than maximum message retention period. The default message retention period is 4 days. However, you can set the message retention period to a value from 60 seconds to 1209600 seconds (14 days) with SetQueueAttributes. |
In the preceding section, we discussed in general terms how your system establishes a queue, confirms it's ready to use, and then starts using it. During use, the various components of your system continually send, receive, and delete messages. The sample libraries available with this guide cover all possible operations available with SQS. However, the examples in this guide focus specifically on the core queue operations:
Creating a queue
Listing your queues
Sending a message to a queue
Retrieving messages from a queue
Deleting a message from a queue
For more specific information about the samples, see Preparing the Samples.
For information about the other operations you can perform with SQS, refer to the Amazon Simple Queue Service Developer Guide.