Skip to content
Kafka Is Fun

BeginnerCore Concepts

What are Kafka's built-in compression types?

Reference answer

Kafka supports GZIP, Snappy, LZ4 and ZStandard. On the producer the compression.type setting accepts none (the default), gzip, snappy, lz4 and zstd, and compression is applied to whole batches, so batching affects the compression ratio. Each codec has a tunable level where applicable (compression.gzip.level, compression.lz4.level, compression.zstd.level). The batch stays compressed in the log and is transmitted to the consumer in compressed form, and the consumer decompresses it. On the broker and topic side, compression.type defaults to producer, which keeps the codec the producer used; it can instead be set to uncompressed or a specific codec. Compressing messages together gives better ratios than compressing each one alone, and sending batches reduces network overhead.

Expected key concepts: GZIP, Snappy, LZ4, ZStandard, compression.type, producer, batch, broker, consumer, decompresses

How did that feel?

Your own verdict, not the score. It shows up next to this question in the list, so you can come back to the shaky ones.