Complete the code to set the maximum poll records for higher throughput.
props.put("max.poll.records", [1]);
Setting max.poll.records to 500 allows the consumer to fetch up to 500 records per poll, improving throughput.
Complete the code to set the fetch size for the consumer to optimize throughput.
props.put("fetch.min.bytes", [1]);
Setting fetch.min.bytes to 50000 means the consumer waits to fetch at least 50KB of data, improving throughput by reducing fetch frequency.
Fix the error in the code to properly commit offsets asynchronously for better throughput.
consumer.[1]((offsets, exception) -> {});Using commitAsync() commits offsets asynchronously, which improves throughput by not blocking the consumer thread.
Fill both blanks to configure the consumer for better throughput by adjusting session timeout and heartbeat interval.
props.put("session.timeout.ms", [1]); props.put("heartbeat.interval.ms", [2]);
Setting session.timeout.ms to 30000 ms and heartbeat.interval.ms to 3000 ms balances consumer liveness detection and heartbeat frequency for throughput optimization.
Fill all three blanks to create a consumer poll loop that maximizes throughput by adjusting poll timeout, processing batch size, and commit frequency.
while (true) { ConsumerRecords<String, String> records = consumer.poll([1]); for (ConsumerRecord<String, String> record : records) { process(record); } if (records.count() >= [2]) { consumer.[3]((offsets, exception) -> {}); } }
Polling with a 1000 ms timeout allows batch fetching, processing batches of 500 records before committing asynchronously improves throughput by reducing commit overhead.