Configure the Details of the GZIP Compression in Payara Platform October 2021 Release

Photo of Rudy De Busscher by Rudy De Busscher

Data is sent to and received from the endpoints within Payara Platform. When large chunks of data are sent to the client in response to a request, it might be an option to compress the data when the bandwidth is limited.  This speeds up the transfer, but requires more CPU on the server and the client to perform the compression and handle the response.

With the October 2021 release, the Payara Platform allows configuring the compression level and the compression algorithm so you can better tune your environment for your requirements.

GZip/Deflate Compression

The compression of the HTTP response can be activated through the protocol settings page within the Admin Console of Payara Server. When activated, the response is compressed using the Deflate algorithm included within Java. This algorithm is also known as GZip.

By default, the http-listener-1 is the listener and protocol that is used for handling the requests of the user.  The HTTP tab contains several options for the protocol, including the option to turn on the compression.  But several parameters determine if the response is compressed based on the size and mime type of the response and the user agents.

config_gzip_compressionAs of Payara Community 5.2021.7 (5.32.0 for the Enterprise Edition), two new fields are added to configure the compression level and strategy. The compression level determines the amount of compression. A value of 0 means no compression whereas 9 results in maximum compression. This is also a tradeoff for the impact on the server performance. A value of 0 does not impact the performance but 9 can have a noticeable influence on the response time.

The default value is equal to level 6, this value is defined by the underlying implementation zlib in Java.

The level determines how intensive, in a small subset or a large subset of the response, the duplicates are searched. The strategy determines how the duplicates are encoded within the output.  The Filtered value just looks at the actual sequence of data and only considers small sequences. The Huffman option uses a replacement sequence like using 'P' for each occurrence of 'Payara'.

The default strategy uses a combination of both options where the filtering option is used to find repetitions and the Huffman encoding to further reduce the result size.

The following asadmin commands can also be used to configure the level and strategy in Payara Server and Payara Micro:

./asadmin set configs.config.server-config.network-config.protocols.protocol.<protocol-name>.http.compression-level=<level>

./asadmin set configs.config.server-config.network-config.protocols.protocol.<protocol-name>.http.compression-strategy=<strategy>

Compression Optimization

After you have activated the compression option, from this version on, you can tweak the performance impact on the server with the two new options.

You can either choose to define a level value lower than 6 to reduce the impact of the compression on the response generation. Changing the level value will have the most impact on the performance. You can also decide to change the strategy to Filtered or Huffman to lower the impact.

Or you can increase the level when the size of the response should be as small as possible due to bandwidth issues.

Configure GZIP Compression

In previous Payara Platform releases, Payara Server and Payara Micro both offered compression, but you had no control over the configuration and how it was compressed. In this release, we have added the possibility to tweak the compression level and strategy so that you have full control over the underlying algorithm.

 Payara Platform  Download Here 

Or you can request Payara Platform Enterprise 5.32.0 here. 

Related Posts

Comments