0
0
Kafkadevops~10 mins

Resource planning and capacity 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 number of partitions for a Kafka topic.

Kafka
newTopic = NewTopic('my-topic', [1], replication_factor=1)
Drag options to blanks, or click blank then click option'
A3
B'3'
Cpartitions
Dreplication_factor
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string instead of an integer for partitions.
Confusing replication_factor with partitions.
2fill in blank
medium

Complete the code to configure the consumer group id.

Kafka
consumer = KafkaConsumer('my-topic', group_id=[1], bootstrap_servers=['localhost:9092'])
Drag options to blanks, or click blank then click option'
A'my-group'
B123
CNone
DTrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number instead of a string for group_id.
Setting group_id to None disables consumer group behavior.
3fill in blank
hard

Fix the error in setting the retention time for a topic.

Kafka
topic_config = {'retention.ms': [1]
Drag options to blanks, or click blank then click option'
A60000ms
B'60000'
Cretention.ms
D60000
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string instead of an integer for retention.ms.
Adding units like 'ms' inside the value.
4fill in blank
hard

Fill both blanks to create a producer with acks set to all and retries set to 5.

Kafka
producer = KafkaProducer(acks=[1], retries=[2])
Drag options to blanks, or click blank then click option'
A'all'
B3
C5
D'none'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number for acks instead of a string.
Setting retries as a string.
5fill in blank
hard

Fill all three blanks to create a topic with 4 partitions, replication factor 2, and cleanup policy set to compact.

Kafka
newTopic = NewTopic('[1]', [2], replication_factor=[3], topic_configs={'cleanup.policy': 'compact'})
Drag options to blanks, or click blank then click option'
Amy-topic
B4
C2
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong data types for partitions or replication factor.
Confusing replication factor with partitions.