0
0
Kafkadevops~10 mins

Auto-scaling strategies 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 minimum number of Kafka partitions to 3.

Kafka
partitions = [1]
Drag options to blanks, or click blank then click option'
A5
B3
C1
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Setting partitions to 0 disables the topic.
Using 1 partition limits scaling.
2fill in blank
medium

Complete the code to increase partitions dynamically using the Kafka admin client.

Kafka
admin_client.create_partitions(topic='my_topic', new_total_partitions=[1])
Drag options to blanks, or click blank then click option'
A1
B2
C6
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Setting partitions less than current causes errors.
Using 0 partitions is invalid.
3fill in blank
hard

Fix the error in the code to correctly configure auto-scaling based on lag.

Kafka
if consumer_lag > [1]:
    scale_up()
Drag options to blanks, or click blank then click option'
A'high_lag'
Bconsumer_lag
C0
D1000
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string instead of a number for comparison.
Comparing lag to itself causes no scaling.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each partition to its lag if lag is greater than 500.

Kafka
partition_lag = {partition: [1] for partition, lag in lags.items() if lag [2] 500}
Drag options to blanks, or click blank then click option'
Alag
B>
C<
Dpartition
Attempts:
3 left
💡 Hint
Common Mistakes
Using partition instead of lag as the value.
Using less than operator reverses the filter.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps each partition to its lag if lag is greater than 1000 and partition number is less than 10.

Kafka
filtered_lags = { [1]: [2] for [3], lag in lags.items() if lag > 1000 and [3] < 10 }
Drag options to blanks, or click blank then click option'
Apartition
Blag
Dindex
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent variable names for partition.
Mapping lag as key instead of value.