Skip to content

Is SNS able to send messages to subscribed SQS in batches?

1

Both SNS and SQS support batching on the input side, but I have not found any evidence that SNS can send messages to subscribed SQS queues in batches.

I have one standard SQS queue subscribed to a standard SNS topic, and in the Cost Explorer, I only see Send API operations, with no SendMessageBatch operations. This leads me to believe that SNS does not send messages in batches to SQS.

We use the SNS-to-SQS pattern for data pipelines with significant traffic, and the lack of batching between these two services has a noticeable impact on our costs.

Is SNS fundamentally able to send messages to subscribed SQS queues in batches? It’s also possible that we have a misconfiguration preventing batching.

EDIT1: I observed this behavior in CloudTrail as well, which confirmed what I saw in Cost Explorer.

EDIT2: I found out that batching between SNS and SQS works for FIFO queues and FIFO topics. Can someone confirm if batching is not supported for standard queues and topics?

EDIT3: I found out that batching between SNS and SQS works also for standard queues and FIFO topics. So problem remains only for standard SNS topic with subscribed SQS queue.

3 Answers
1
Accepted Answer

The standard SNS topics do not support batching as a feature, even when PublishBatch API is used, due to an internal delivery mechanism that differs from SNS FIFO. If you need batched delivery to SQS, you should use SNS FIFO topics to deliver to both standard and FIFO SQS queues.

AWS

answered 2 years ago

  • Hello @Lefteris Karageorgiou - AWS, Thank you very much for your clarification. This is very helpful to us. We were confused because we couldn’t find this information in the AWS documentation, which is usually very thorough. Considering its importance from a cost-efficiency perspective, I would have expected this information to be more prominently visible.

1

Hello @Tomas Bartek

If you send a batch of messages to SNS using the PublishBatch API, SQS's SendMessageBatch API will deliver the messages. You can test it by using cloudtrail to track the SQS API calls and delivering messages to SNS in batches.

If the Answer is helpful, please click Accept Answer & UPVOTE, this can be beneficial to other community members.

answered 2 years ago

  • Hello @learn2skills, I tried it in a testing environment with a created CloudTrail trail, but unfortunately, for the PublishBatch API call, I only received SendMessage API calls.

    I made only SNS PublishBatch requests using the CLI to be sure about the results. I also tried setting the "raw message delivery" parameter in the SNS subscription to False, but nothing helped.

    Please, have you tried it recently? Maybe something has changed?

1

Hi,

It seems to be a supported feature: https://docs.aws.amazon.com/sns/latest/dg/sns-batch-api-actions.html

Thanks

answered 2 years ago

  • Hello @myronix88, Yes, SNS supports batching on the input side with the PublishBatch API, but I'm encountering a problem with sending messages from SNS to a subscribed SQS, where batching doesn't seem to work.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.