0
0
Kafkadevops~10 mins

Configuration best practices 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 bootstrap servers for Kafka producer configuration.

Kafka
props.put("bootstrap.servers", [1]);
Drag options to blanks, or click blank then click option'
A"broker:2182"
B"127.0.0.1"
C"localhost:9092"
D"kafka:2181"
Attempts:
3 left
💡 Hint
Common Mistakes
Using zookeeper port 2181 instead of Kafka broker port 9092.
Omitting the port number.
Using an IP without port.
2fill in blank
medium

Complete the code to set the key serializer class for Kafka producer.

Kafka
props.put("key.serializer", [1]);
Drag options to blanks, or click blank then click option'
A"org.apache.kafka.common.serialization.StringDeserializer"
B"org.apache.kafka.common.serialization.StringSerializer"
C"org.apache.kafka.common.serialization.ByteArraySerializer"
D"org.apache.kafka.common.serialization.IntegerDeserializer"
Attempts:
3 left
💡 Hint
Common Mistakes
Using deserializer class instead of serializer.
Using wrong serializer for key type.
3fill in blank
hard

Fix the error in setting the 'acks' configuration for Kafka producer to ensure all replicas acknowledge.

Kafka
props.put("acks", [1]);
Drag options to blanks, or click blank then click option'
A"all"
B"0"
C"1"
D"-1"
Attempts:
3 left
💡 Hint
Common Mistakes
Using '1' which waits only for leader acknowledgement.
Using '0' which disables acknowledgement.
4fill in blank
hard

Fill both blanks to configure the producer retries and retry backoff time.

Kafka
props.put("retries", [1]);
props.put("retry.backoff.ms", [2]);
Drag options to blanks, or click blank then click option'
A3
B100
C0
D500
Attempts:
3 left
💡 Hint
Common Mistakes
Setting retries to 0 disables retries.
Setting retry.backoff.ms too high causes delays.
5fill in blank
hard

Fill all three blanks to configure the consumer group id, enable auto commit, and set auto commit interval.

Kafka
props.put("group.id", [1]);
props.put("enable.auto.commit", [2]);
props.put("auto.commit.interval.ms", [3]);
Drag options to blanks, or click blank then click option'
A"my-group"
Btrue
C1000
Dfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using false for enable.auto.commit disables auto commit.
Setting auto.commit.interval.ms too low or too high affects performance.