Overview
Producers batch records before sending, which spreads the overhead of a network round trip over many records. linger.ms is an upper bound on how long to wait for more records: once batch.size worth of records for a partition is ready, it is sent immediately. batch.size is per partition. compression.type accepts none (the default), gzip, snappy, lz4 or zstd and is applied to whole batches. A batch stays compressed in the log and is sent to consumers compressed; consumers decompress it, and the broker decompresses a batch to validate it. Broker and topic compression.type default to producer, which keeps the producer's codec.
Key configuration
linger.ms=5 — the default since Kafka 4.0 (it was 0 before)
batch.size=16384 — default, 16 KiB per partition
compression.type=lz4 — one of none (default), gzip, snappy, lz4, zstdProduction tip
Check yourself
Where is a compressed batch decompressed?
Sources
- Producer configs (4.2 documentation) (opens in a new tab)
- Design (4.2 documentation) (opens in a new tab)
- Topic configs (4.2 documentation) (opens in a new tab)
- Broker configs (4.2 documentation) (opens in a new tab)
Checked against Kafka 4.2 documentation on Oct 2026. Draft: not yet reviewed by a Kafka specialist. Releases move on, so confirm against the current documentation before you act on a number.