This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Compressing Messages
All messages published to WSO2 MB are stored in a database, which guarantees message persistence. From WSO2 MB 3.1.0 onwards, you can reduce the overhead on the database by compressing (i.e., reducing the message content size) the messages using LZ4 compression. This will reduce the number of message content chunks, which in turn will reduce the number of records in the database. This is an optional configuration that you can set up in the message broker.Â
Find out more about how this configuration improves the performance of your MB server.
Follow the steps given below to enable message content compression for your server.
- Open the
broker.xml
file from the<MB_HOME>/repository/conf
directory. Enable compression by setting the following property to 'true'.
<!-- This is the configuration to allow compression of message contents, before store messages into the database.--> <allowCompression>false</allowCompression>
Specify the message content compression threshold using the following parameter. This is the minimum content size a message should have in order to be compressed. Messages smaller than this size will not be compressed, even if compression is enabled for the server.
<!-- This is the configuration to change the value of the content compression threshold (in bytes). Message contents less than this value will not compress, even compression is enabled. The recommended message size of the smallest message before compression is 13 bytes. Compress messages smaller than 13 bytes will expand the message size by 0.4% --> <contentCompressionThreshold>1000</contentCompressionThreshold>
Note the following when you set this parameter:Â
If you set a very low value, the message size will increase due to the lack of repeated content.Â
It is not recommended to compress messages that are smaller than 13 bytes.
This value effects the performance of your server: Lower values will reduce server performance. Higher values (greater than 1000) would increase performance.
Specify values for the following parameters, which will determine the speed of the message sending mechanism:
TheÂ
<parallelDecompressionHandlers>
 parameter specifies the total number of parallel decompression handlers that are used to decompress the message content before they are sent to subscribers.ÂTheÂ
<parallelContentReaders>
 parameter specifies the number of parallel readers used to read content from the message store.TheÂ
<parallelDeliveryHandlers>
 parameters specifies the number of parallel delivery handlers used to deliver messages to subscribers.
<parallelDecompressionHandlers>5</parallelDecompressionHandlers> <parallelContentReaders>5</parallelContentReaders> <parallelDeliveryHandlers>5</parallelDeliveryHandlers>
Note the following when you set this parameter:
Reducing this value would decrease the speed of the message sending mechanism, but also reduce the load on the message store.Â
Increasing this value would increase the speed of the message sending mechanism because multiple handlers are working in parallel. However, the load on the message store would also increase.Â
A higher number of cores is required to increase this value.Â
The speed of the message sending mechanism depends on all three parameters given above. Therefore, it is recommendation to set the same (or nearly same) value for all of them.