0
0
Kafkadevops~20 mins

Batch size and compression tuning in Kafka - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Kafka Batch & Compression Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Effect of batch.size on message sending

Consider a Kafka producer configured with batch.size=16384 bytes and linger.ms=0. The producer sends messages of 1000 bytes each. How many messages will be sent in one batch if the producer is continuously sending messages?

A16384 messages
B1 message
C16 messages
D0 messages
Attempts:
2 left
💡 Hint

Batch size limits the total bytes in a batch. Divide batch size by message size.

Predict Output
intermediate
2:00remaining
Compression type impact on message size

A Kafka producer sends a batch of 100 messages, each 1KB uncompressed. The producer uses compression.type=gzip. After compression, the batch size is 50KB. What is the approximate compression ratio?

A2:1
B0.5:1
C50:100
D1:2
Attempts:
2 left
💡 Hint

Compression ratio = uncompressed size / compressed size.

Predict Output
advanced
2:00remaining
Producer batch sending timing with linger.ms

A Kafka producer has batch.size=32768 bytes and linger.ms=100. It sends messages of 5000 bytes each. If the producer sends 3 messages quickly, what happens?

AThe producer sends the batch immediately after the first message.
BThe producer waits indefinitely until batch is full.
CThe producer sends each message immediately without waiting.
DThe producer waits 100ms before sending the batch of 3 messages.
Attempts:
2 left
💡 Hint

Consider how linger.ms affects batching when batch is not full.

Predict Output
advanced
2:00remaining
Effect of compression.type=snappy on CPU usage

Which of the following is true about using compression.type=snappy in Kafka producers compared to gzip?

ASnappy uses less CPU and compresses faster but with lower compression ratio than gzip.
BSnappy uses more CPU and compresses slower but with higher compression ratio than gzip.
CSnappy and gzip have identical CPU usage and compression ratio.
DSnappy does not compress data, only encrypts it.
Attempts:
2 left
💡 Hint

Think about speed vs compression trade-offs.

🧠 Conceptual
expert
3:00remaining
Choosing optimal batch size and compression for high throughput

You want to maximize Kafka producer throughput for large messages (~1MB each) on a network with moderate latency. Which combination is best?

ASet batch.size to 1MB and disable compression to reduce CPU usage.
BSet batch.size to 5MB and use compression.type=lz4 for fast compression and decompression.
CSet batch.size to 512KB and use compression.type=gzip for maximum compression ratio.
DSet batch.size to 100KB and use compression.type=snappy for minimal latency.
Attempts:
2 left
💡 Hint

Consider message size, network latency, and compression speed.