Menu
Amazon Simple Queue Service
Developer Guide

Amazon SQS Batch API Actions

In the 2009-02-01 API version of Amazon SQS, only the ReceiveMessage action supports batch processing (processing more than one message with a single call).

From the 2011-10-01 API version of Amazon SQS, you can use batch functionality to send and delete messages and to change the message visibility timeout:

  • To send up to ten messages at once, use the SendMessageBatch action.

  • To delete up to ten messages with one API call, use the DeleteMessageBatch action.

  • To change the visibility timeout value for up to ten messages, use the ChangeMessageVisibilityBatch action.

To reduce costs, take advantage of batch functionality by using the Query API or a Software Development Kit (SDK) that supports the new Amazon SQS batch actions.

Note

The Amazon SQS console does not support batch API actions.

For details and examples of the following three batch API actions, see the Amazon Simple Queue Service API Reference:

Maximum Message Size for SendMessageBatch

You can send a message as large as 262,144 bytes (256 KB) with SendMessageBatch. However, the total size of all the messages that you send in a single call to SendMessageBatch can't exceed 262,144 bytes (256 KB).

On this page:

  • Maximum Message Size for SendMessageBatch
  • Client-Side Buffering and Request Batching Enable client-side buffering, where calls made from the client are first buffered and then sent as a batch request to Amazon SQS. The AWS SDK for Java (http://aws.amazon.com/sdkforjava/) includes a buffered asynchronous client, AmazonSQSBufferedAsyncClient, for accessing Amazon SQS. This new client allows for easier request batching by enabling client-side buffering, where calls made from the client are first buffered and then sent as a batch request to Amazon SQS. Client-side buffering allows up to 10 requests to be buffered and sent as a batch request instead of sending each request separately. As a result, your cost of using Amazon SQS decreases as you reduce the number of requests sent to the service. AmazonSQSBufferedAsyncClient buffers both synchronous and asynchronous calls. Batched requests and support for long polling can also help increase throughput (the number of messages transmitted per second). For more information, see and . Migrating from the asynchronous client, AmazonSQSAsyncClient, to the buffered asynchronous client, AmazonSQSBufferedAsyncClient, should require only minimal changes to your existing code. This is because AmazonSQSBufferedAsyncClient implements the same interface as AmazonSQSAsyncClient. The Amazon SQS Buffered Asynchronous Client doesn't currently support FIFO queues.
  • Getting Started with AmazonSQSBufferedAsyncClient
  • Advanced Configuration
  • Increasing Throughput with Horizontal Scaling and Batching Increase throughput in Amazon SQS with horizontal scaling and batching with a simple example you can try for yourself. Amazon SQS queues can deliver very high throughput (many thousands of messages per second). The key to achieving this throughput is to horizontally scale message producers and consumers. In addition, you can use the batching actions in the Amazon SQS API to send, receive, or delete up to 10 messages at a time. In conjunction with horizontal scaling, batching achieves a given throughput with fewer threads, connections, and requests than would be required by individual message requests. Because Amazon SQS charges by the request instead of by the message, batching can also substantially reduce costs. This appendix discusses horizontal scaling and batching in more detail. It then walks through a simple example that you can try out yourself. It also briefly discusses Amazon SQS throughput metrics that you can monitor by using CloudWatch.
  • Horizontal Scaling
  • Batching
  • Example
  • Running the Example