All concepts
Scale & performance

Batching

Send and receive up to 10 messages per API call.

Why it matters

Batching can cut API costs by up to 10× and dramatically increase throughput, especially for FIFO queues.

Batch API limits

Amazon SQS batch APIs accept up to 10 messages per request. Total payload size per batch must not exceed 256 KB. Each API returns per-message success and failure — partial batch failures are normal and must be handled.

  • SendMessageBatch: up to 10 messages.
  • ReceiveMessage MaxNumberOfMessages: up to 10.
  • DeleteMessageBatch / ChangeMessageVisibilityBatch: up to 10 receipt handles.

SendMessageBatch

Send up to 10 messages in one API call. The response includes Successful and Failed arrays — retry only the failed entries, not the entire batch.

SendMessageBatch({
  QueueUrl,
  Entries: messages.map((m, i) => ({
    Id: String(i),
    MessageBody: m.body,
    MessageGroupId: m.groupId,       // FIFO
    MessageDeduplicationId: m.dedupId // FIFO
  }))
})

Receive and delete in batches

Set MaxNumberOfMessages to 10 on ReceiveMessage. After processing, delete all successful messages in one DeleteMessageBatch call. For FIFO high-throughput, batch receipt handles from a single receive when calling delete or change visibility.

Client-side buffering

AWS SDKs offer buffered clients (e.g. AmazonSQSBufferedAsyncClient, SqsAsyncBatchManager) that automatically batch requests client-side, reducing API calls further. Note: the Java buffered async client does not support FIFO queues.

  • Default max batch size: 10 (SQS hard limit).
  • Default batch open window: ~200ms.
  • Combine with long polling for maximum throughput.

Lambda integration

Lambda's SQS event source mapping supports partial batch failures. Return batchItemFailures with the itemIdentifier of failed messages — Lambda re-queues only those, not the whole batch.

Gotchas
  • !Partial batch failures must be handled explicitly — iterate Successful and Failed arrays.
  • !Without Lambda batchItemFailures, one failed message fails the entire batch — successful messages get reprocessed.
  • !FIFO SendMessageBatch: batch same MessageGroupId when possible for partition efficiency.
Try the Lost batches lab
Apply this concept to a broken system.
open →