0
0
Kafkadevops~20 mins

Disk I/O optimization in Kafka - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Kafka Disk I/O Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Understanding Kafka Disk Flush Behavior
What is the output of the following Kafka producer configuration snippet regarding disk flush frequency?
Kafka
props.put("linger.ms", "500");
props.put("batch.size", "16384");
props.put("acks", "all");
// Producer sends 10 messages rapidly
for (int i = 0; i < 10; i++) {
    producer.send(new ProducerRecord<>("topic", Integer.toString(i), "message" + i));
}
producer.flush();
System.out.println("Messages sent and flushed.");
AMessages sent and flushed. Producer never flushes automatically; manual flush is required only.
BMessages sent and flushed. Producer flushes after every single message immediately.
CMessages sent and flushed. Producer batches messages and flushes every 500ms or when batch size is reached.
DMessages sent and flushed. Producer flushes only after 10 seconds regardless of batch size.
Attempts:
2 left
💡 Hint
Think about how linger.ms and batch.size affect when Kafka flushes data to disk.
🧠 Conceptual
intermediate
1:30remaining
Effect of Kafka Log Segment Size on Disk I/O
How does increasing the Kafka log segment size affect disk I/O performance?
ALog segment size has no effect on disk I/O performance in Kafka.
BLarger log segments reduce the frequency of disk flushes, improving sequential disk writes and reducing I/O overhead.
CLarger log segments increase random disk writes, causing more disk I/O overhead.
DSmaller log segments always improve disk I/O by reducing disk seek times.
Attempts:
2 left
💡 Hint
Think about how disk writes benefit from sequential large writes versus many small writes.
🔧 Debug
advanced
2:30remaining
Identifying Disk I/O Bottleneck in Kafka Consumer
Given this Kafka consumer code snippet, which option correctly identifies the cause of high disk I/O latency?
Kafka
consumer.subscribe(Collections.singletonList("topic"));
while (true) {
    ConsumerRecords<String, String> records = consumer.poll(Duration.ofMillis(100));
    for (ConsumerRecord<String, String> record : records) {
        process(record.value());
        consumer.commitSync();
    }
}
ASubscribing to a single topic causes disk I/O bottleneck due to lack of parallelism.
BPolling every 100ms causes excessive disk I/O and should be increased to 1000ms.
CNot using commitAsync() causes disk I/O latency due to synchronous commits.
DCalling commitSync() inside the for-loop causes frequent disk writes, increasing disk I/O latency.
Attempts:
2 left
💡 Hint
Consider how often commitSync() writes to disk and its impact on performance.
📝 Syntax
advanced
2:00remaining
Correct Kafka Producer Configuration for Disk I/O Optimization
Which option shows the correct Java code snippet to configure a Kafka producer for optimized disk I/O with compression and batching?
A
props.put("compression.type", "snappy");
props.put("batch.size", 32768);
props.put("linger.ms", 100);
B
props.put("compression", "snappy");
props.put("batchSize", "32768");
props.put("linger", 100);
C
props.put("compression.type", snappy);
props.put("batch.size", "32768");
props.put("linger.ms", "100");
D
props.put("compression.type", "gzip");
props.put("batch.size", 100);
props.put("linger.ms", 1000);
Attempts:
2 left
💡 Hint
Check property names and value types carefully.
🚀 Application
expert
3:00remaining
Optimizing Kafka Broker Disk Usage for High Throughput
You manage a Kafka cluster with high disk I/O load. Which configuration change will most effectively reduce disk I/O pressure on brokers while maintaining high throughput?
AIncrease log.segment.bytes to a larger size and enable log compaction to reduce disk writes.
BDecrease log.retention.hours to delete old logs faster and reduce disk usage.
CSet num.io.threads to 1 to serialize disk access and reduce contention.
DDisable log.cleaner to avoid extra disk I/O from compaction processes.
Attempts:
2 left
💡 Hint
Think about how log segment size and compaction affect disk write patterns.