0
0
Kafkadevops~20 mins

Batching and linger configuration in Kafka - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Kafka Batching Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Effect of linger.ms on message batching
Consider a Kafka producer configured with linger.ms=100. The producer sends messages every 50ms. What is the expected behavior regarding message batching?
Kafka
producer_config = {
  'linger.ms': 100
}

# Messages sent every 50ms
# How does linger.ms affect batching here?
AMessages are sent immediately without batching because 50ms < linger.ms
BMessages are delayed indefinitely until batch size is reached
CMessages are batched and sent every 100ms or when batch is full
DMessages are sent every 50ms ignoring linger.ms
Attempts:
2 left
💡 Hint
Think about how linger.ms controls the maximum wait time before sending a batch.
Predict Output
intermediate
2:00remaining
Batch size effect on Kafka producer throughput
A Kafka producer has batch.size=16384 bytes and linger.ms=0. If the producer sends messages smaller than 1KB each rapidly, what is the expected behavior?
Kafka
producer_config = {
  'batch.size': 16384,  # 16 KB
  'linger.ms': 0
}

# Messages are ~1KB each, sent rapidly
AMessages are dropped if batch size is not reached
BMessages are batched up to 16KB before sending
CMessages are delayed up to linger.ms before sending
DEach message is sent immediately without batching
Attempts:
2 left
💡 Hint
What does linger.ms=0 imply about waiting for batch completion?
🔧 Debug
advanced
2:00remaining
Identify the cause of delayed message sending
A Kafka producer is configured with linger.ms=500 and batch.size=32768. However, messages are delayed longer than 500ms before sending. What is the most likely cause?
Kafka
producer_config = {
  'linger.ms': 500,
  'batch.size': 32768
}

# Messages are sent slowly, delays > 500ms observed
AThe producer is waiting for acknowledgments before sending next batch
BThe batch size is too large, causing delays waiting for batch to fill
Clinger.ms is ignored if batch.size is not reached
DThe network latency causes linger.ms to be ineffective
Attempts:
2 left
💡 Hint
Consider how batch.size and linger.ms interact to trigger sending.
📝 Syntax
advanced
2:00remaining
Correct Kafka producer configuration syntax for batching
Which of the following Kafka producer configuration snippets correctly sets batch.size to 32KB and linger.ms to 100ms in Java?
A
props.put("batch.size", 32 * 1024);
props.put("linger.ms", 100);
B
props.put("batch.size", "32768");
props.put("linger.ms", "100");
C
props.put(batch.size, 32768);
props.put(linger.ms, 100);
D
props.put("batch.size", 32768);
props.put("linger.ms", 100);
Attempts:
2 left
💡 Hint
Check for correct key names as strings and valid value types.
🚀 Application
expert
3:00remaining
Optimizing Kafka producer for low latency and high throughput
You want to configure a Kafka producer to achieve low latency but still benefit from batching to improve throughput. Which configuration is best?
ASet linger.ms to a small positive value (e.g., 5ms) and batch.size to a moderate value
BSet linger.ms to 0 and batch.size to a large value
CSet linger.ms to a large value (e.g., 500ms) and batch.size to a small value
DSet linger.ms to a large value and batch.size to a large value
Attempts:
2 left
💡 Hint
Think about balancing wait time and batch size for latency and throughput.