0
0
Kafkadevops~10 mins

Consumer throughput optimization in Kafka - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the maximum poll records for higher throughput.

Kafka
props.put("max.poll.records", [1]);
Drag options to blanks, or click blank then click option'
A500
B1000
C10
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Setting max.poll.records too low limits throughput.
Using a value too high can cause long processing delays.
2fill in blank
medium

Complete the code to set the fetch size for the consumer to optimize throughput.

Kafka
props.put("fetch.min.bytes", [1]);
Drag options to blanks, or click blank then click option'
A1
B50000
C1000
D100
Attempts:
3 left
💡 Hint
Common Mistakes
Setting fetch.min.bytes too low causes many small fetches.
Too high a value can increase latency.
3fill in blank
hard

Fix the error in the code to properly commit offsets asynchronously for better throughput.

Kafka
consumer.[1]((offsets, exception) -> {});
Drag options to blanks, or click blank then click option'
Acommit
BcommitOffset
CcommitAsync
DcommitSync
Attempts:
3 left
💡 Hint
Common Mistakes
Using commitSync causes blocking and reduces throughput.
Using a non-existent commit method causes runtime errors.
4fill in blank
hard

Fill both blanks to configure the consumer for better throughput by adjusting session timeout and heartbeat interval.

Kafka
props.put("session.timeout.ms", [1]);
props.put("heartbeat.interval.ms", [2]);
Drag options to blanks, or click blank then click option'
A30000
B10000
C3000
D1000
Attempts:
3 left
💡 Hint
Common Mistakes
Setting heartbeat interval higher than session timeout causes consumer to be considered dead.
Too low session timeout causes frequent rebalances.
5fill in blank
hard

Fill all three blanks to create a consumer poll loop that maximizes throughput by adjusting poll timeout, processing batch size, and commit frequency.

Kafka
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) -> {});
    }
}
Drag options to blanks, or click blank then click option'
A1000
B500
CcommitAsync
DcommitSync
Attempts:
3 left
💡 Hint
Common Mistakes
Using commitSync blocks the consumer and reduces throughput.
Polling with too low timeout fetches fewer records, reducing throughput.