Challenge - 5 Problems
Kafka Disk I/O Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2: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.");
Attempts:
2 left
💡 Hint
Think about how linger.ms and batch.size affect when Kafka flushes data to disk.
✗ Incorrect
The linger.ms setting controls how long the producer waits before sending a batch, allowing more messages to accumulate. The batch.size sets the max batch size. The producer flushes when either condition is met. So, messages are batched and flushed every 500ms or when batch size is reached.
🧠 Conceptual
intermediate1:30remaining
Effect of Kafka Log Segment Size on Disk I/O
How does increasing the Kafka log segment size affect disk I/O performance?
Attempts:
2 left
💡 Hint
Think about how disk writes benefit from sequential large writes versus many small writes.
✗ Incorrect
Increasing log segment size means Kafka writes larger chunks sequentially to disk less often, which reduces disk seeks and overhead, improving disk I/O performance.
🔧 Debug
advanced2: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(); } }
Attempts:
2 left
💡 Hint
Consider how often commitSync() writes to disk and its impact on performance.
✗ Incorrect
Calling commitSync() inside the loop commits offsets after every record, causing many small disk writes and increasing disk I/O latency. Committing offsets less frequently reduces disk I/O overhead.
📝 Syntax
advanced2: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?
Attempts:
2 left
💡 Hint
Check property names and value types carefully.
✗ Incorrect
Option A uses correct property names and appropriate value types for compression.type, batch.size, and linger.ms. Other options have incorrect property names, missing quotes, or inappropriate values.
🚀 Application
expert3: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?
Attempts:
2 left
💡 Hint
Think about how log segment size and compaction affect disk write patterns.
✗ Incorrect
Increasing log segment size reduces the frequency of disk flushes, improving sequential writes. Enabling log compaction removes redundant data, reducing disk usage and I/O. Other options either reduce data retention without improving throughput or reduce parallelism causing bottlenecks.