Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable compression for AWS SQS Java API or how to tell if it's already on?

I'm doing some processing of AWS SQS messages and noticed that the process is network-bound.

The messages are highly-compressible large JSON content, and they were dropped into the queue without any compression on the payload itself.

Does the AWS SQS API perform compression on the wire? If optional, how can I enable it?

A Google search for AWS SQS API compression yields a bunch of information on AWS API Gateway, which is totally unrelated to my question.

like image 530
Alex R Avatar asked Sep 06 '25 14:09

Alex R


2 Answers

SQS does not support automatic/transparent compression.

To compress messages, you'd have to compress the payload yourself (e.g. with gzip) and then you'd have to encode the compressed data with base64, because SQS supports only character data -- valid utf8 -- not raw binary data.

(Additionally it seems unlikely that you are network-bound when polling. You may need to investigate this in more detail.)

like image 168
Michael - sqlbot Avatar answered Sep 08 '25 04:09

Michael - sqlbot


If ur messages are more than 256 KB,either split it and if u cannot split it put it on S3 and send the s3 link as a message in queue. GZIP and then Base64 ends up increasing message size...It is not worth the effort to try that.. I spent close to an hour trying this with various text and json messages..I was not getting any considerable saving in message size after gzipping and base64 encoding..

On Small text size messages, my zipped and base64 message was around 30 percent higher in size than simple text message

like image 21
MrWayne Avatar answered Sep 08 '25 05:09

MrWayne