...
Public Interfaces
This feature introduces a 3 new optionoptions, 'compression.gzip.level','compression.lz4.level' and 'compression.snappy.level' to the producer, topic, and broker configuration. Snappy is excluded since it does not support any compression level. The type of this option these options is an integer, with a default value of null..
For example
Code Block | ||
---|---|---|
| ||
compression.type=gzip
compression.gzip.level=4 # NEW: Compression level to be used. |
The table below shows the valid range of compression. level per compression.type. (note: snappy is excluded since it does not support any compression level.) If the level is not explicitly set by the user, the default value from the compression library will be used like it is done today. The valid range and default value of the compression level are entirely up to the compression library, so they may be changed in the future.
Compression Codecavailability | Valid Range | Default | |
---|---|---|---|
gzip | Yes | 1 (Deflater.BEST_SPEED) ~ 9 (Deflater.BEST_COMPRESSION) | 6 |
snappy | No | - | - |
lz4 | Yes | 1 ~ 179 | |
zstdYes | -131072 ~ 223 |
Proposed Changes
This option impacts the following processes:
...
- If 'compression.type' is none of or snappy, 'compression.<codec>.level' is ignored.
- If 'compression.<codec>.level' is not in the valid range, it raises an error.
- If If 'compression.<codec>.level' is in the valid range, the producer compresses the records with the given level.
- If If 'compression.<codec>.level' is not set, it falls back to the default level.
...
Since this update follows the default compression level and current buffer size if they are not set, there is no backward compatibility problem.
Rejected Alternatives
...
Further works
Alongside the compression level, I am trying additional configuration options, like the following:
Compression buffer size option
...
At the initial stage, I considered the compression buffer size option was also under consideration. However, during the benchmark, I could not find any its positive impacts on produce speed nor or compressed size. I am still investigating whether it can improve the disk write speed, e.g., Broker-size recompression or compaction.
Long window size with Zstandard
With 1.3.2, Zstandard introduced compression/decompression with long window size. This option can improve the compression/decompression speed for some levels.
Rejected Alternatives
- Introduce a single configuration: compression.level. This was the original proposal that was voted. However while reviewing the PR we noticed that it was hard to use as each codec has its own range of compression levels. So
...
- for example setting compression.level to 20 would be valid with zstd but an error with gzip. Also a follow up KIP, KIP-780, aims at introducing per codec configurations using the compression.<codec>.<option> syntax. For these reason, it seems preferable to use configurations with the 'compression.<codec>.level' format for consistency.