Integration / Apache Kafka Interview questions
How does Kafka support message compression?
A producer can compress an entire batch of records before sending it over the network, using a codec set via compression.type, and that batch stays compressed as it's stored on the broker's disk and replicated to followers — the broker doesn't decompress and recompress it, which keeps compression's benefit intact all the way through storage and replication, not just the initial network hop.
| Codec | Trade-off |
| gzip | Highest compression ratio, highest CPU cost, slower. |
| snappy | Fast, moderate compression, low CPU cost. |
| lz4 | Very fast, good balance of speed and ratio; common default choice. |
| zstd | Strong compression ratio with good speed; generally the modern recommended default. |
Because compression works on a whole batch rather than record by record, larger batches (via a higher batch.size/linger.ms) generally compress more effectively, which is one more reason producer batching and compression tuning are usually considered together rather than independently. The consumer decompresses transparently based on metadata in the batch header, requiring no consumer-side configuration to match the producer's chosen codec.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
