Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Public Interfaces

This feature introduces two new options, 'compression.level' and 'the following new options to producer, topic, and broker configuration.

Producer

NameDescription

compression.level

Compression level to be used by a producer.
compression.buffer.sizeThe size of compression buffer to be used by a producer.

Topic and Broker

NameDescription
compression.levelCompression level to be used by a broker, if 'compression.type' is 'none' nor 'producer.'
compression.buffer.sizeThe size of compression buffer to be usedby a broker,

...

if 'compression.type' is 'none' nor 'producer.'
compression.[gzip,snappy,lz4, zstd].levelCompression level to be used by a broker, if 'compression.type' is 'producer' and the compression type of produced record is 'gzip', 'snappy', 'lz4', or 'zstd.'
compression.[gzip,snappy,lz4, zstd].buffer.sizeThe size of compression buffer to be usedby a broker, if 'compression.type' is 'producer' and the compression type of produced record is 'gzip', 'snappy', 'lz4', or 'zstd.'

The valid range and default value of compression level and buffer size are

  • If specified option is not supported for the codec ('compression.type'), it is ignored (e.g., compression level for snappy or buffer size for zstd.)
  • If specified value is not available (or invalid), it raises an error.
  • If there is no specified value, it falls back to the default one.

compression.level

The valid range and the default compression level is entirely up to the compression library, so they may be changed in the future. Their current values are like following:

Compression level

Compression CodecavailabilityMinimum LevelMaximum LevelValid RangeCurrent Default
gzipYes1 (Deflater.BEST_SPEED) ~ 9 (1)Deflater.BEST_COMPRESSION (9)6
snappyNo---
lz4Yes1 ~ 179
zstdYes-131072 ~ 223

...

Compression buffer

...

size

...

Compression CodecavailabilityValid ValuesRangeDefault SizeNote
gzipYesPositive Integer8192 (8kb)Kafka's own default.
snappyYesPositive Integer32768 (32kb)Library default.
lz4Yes4~7 4 ~ 7 (4=64kb, 5=256kb, 6=1mb, 7=4mb)4 (64kb)Kafka's own default.
zstdNo---

Proposed Changes

The compression will be done with the new options.

Producer

The record batches will be compressed with the specified level using a compression buffer with specified sizethe specified compression buffer size.

  • If the specified option is not supported for the codec ('compression.type'), it is ignored (e.g., compression level for snappy or buffer size for zstd.)
  • If the specified value is not available (or invalid), it raises an error.
  • If there is no specified value, it falls back to the default one.

Broker

After the offsets are assigned to the record batches sent by the producer, they will be recompressed like following:

  • For all options,
    • Topic configuration comes first; if it is not set, broker configuration is used. (In other words, topic configuration overrides the broker configuration.)
    • If the specified option is not supported for the codec ('compression.type'), it is ignored (e.g., compression level for snappy or buffer size for zstd.)
    • If there is no specified value, it falls back to the default one.
  • If 'compression.type' is not 'none' or 'producer', the record batches will be recompressed using 'compression.type' codec with 'compression.level' and 'compression.buffer.size.' If either of those values is not available (or invalid), it raises an error.
  • If 'compression.type' is 'producer', the record batches will be recompressed using the same codec with corresponding 'compression.[gzip,snappy,lz4,zstd].level' and 'compression.[gzip,snappy,lz4,zstd].buffer.size.' If either of those values is not available (or invalid), it raises an error.

Compatibility, Deprecation, and Migration Plan

...