0
0
Kafkadevops~20 mins

Compression (gzip, snappy, lz4) in Kafka - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Kafka Compression Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this Kafka producer compression setting?
Consider a Kafka producer configured with the following properties:

props.put("compression.type", "gzip");
props.put("batch.size", 16384);
props.put("linger.ms", 5);

What compression type will Kafka use to compress the messages before sending?
Agzip compression
Bsnappy compression
Clz4 compression
Dno compression
Attempts:
2 left
💡 Hint
Check the value assigned to the 'compression.type' property.
Predict Output
intermediate
2:00remaining
What error occurs with unsupported compression codec in Kafka?
Given this Kafka producer configuration:

props.put("compression.type", "brotli");

What happens when the producer tries to send messages?
AMessages are sent without compression
BProducer silently ignores the compression setting
CMessages are compressed using gzip as fallback
DKafka throws an IllegalArgumentException at runtime
Attempts:
2 left
💡 Hint
Check Kafka's supported compression codecs.
🚀 Application
advanced
2:00remaining
How to configure Kafka consumer to decompress messages compressed with snappy?
You have a Kafka topic where messages are compressed using snappy by the producer.

Which consumer configuration ensures messages are decompressed correctly?
ASet 'compression.type' to 'snappy' in consumer properties
BNo special configuration needed; Kafka consumer auto-detects compression
CSet 'fetch.min.bytes' to a higher value
DSet 'enable.auto.commit' to false
Attempts:
2 left
💡 Hint
Think about how Kafka consumers handle compression.
🧠 Conceptual
advanced
2:00remaining
Why might you choose lz4 compression over gzip in Kafka?
Select the main reason to prefer lz4 compression instead of gzip for Kafka message compression.
Alz4 is the only compression supported by Kafka brokers
Blz4 produces the smallest compressed files compared to gzip
Clz4 offers faster compression and decompression speeds with moderate compression ratio
Dlz4 compression is more CPU intensive than gzip
Attempts:
2 left
💡 Hint
Consider speed vs compression ratio trade-offs.
🔧 Debug
expert
3:00remaining
What is the cause of this Kafka producer runtime error with gzip compression?
A Kafka producer configured with:

props.put("compression.type", "gzip");
props.put("batch.size", 0);

When sending messages, it throws:

java.lang.IllegalArgumentException: batch.size must be > 0

What is the root cause?
Abatch.size cannot be zero; it must be a positive integer
Bgzip compression requires batch.size to be at least 16384
Ccompression.type 'gzip' is incompatible with batch.size setting
Dlinger.ms must be set when using gzip compression
Attempts:
2 left
💡 Hint
Check the error message carefully.