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/.

Configuring Message Compression

All messages published to the EI Message Broker are stored in a database, which guarantees message persistence. 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 broker.

Follow the steps given below to enable message content compression for your server.

  1. Open the broker.xml file from the <EI_HOME>/wso2/broker/conf directory.
  2. 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>
  3. 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.

  4. 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 recommended to set the same (or nearly same) value for all of them.