Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

partition.assignment.strategy#

Sumit Rawal answered on June 1, 2023 Popularity 3/10 Helpfulness 1/10

Contents


More Related Answers


partition.assignment.strategy#

0

Topic partitions are assigned to consumers. The assignment of partitions to consumers can be controlled by the class PartitionAssignor. If left to Kafka, there are two assignment strategies:

Range: This scheme assigns a consecutive subset of topic partitions to subscribing consumers. Consider two consumers, C1 and C2, and two topics, T1 and T2. Say, T1 has 3 partitions and T2 has 2 partitions. The algorithm will assign partitions 0 and 1 of T1 to the first consumer C1 and partition 2 of T1 to the second consumer C2. For T2, partition 0 will be assigned to C1 and partition 1 will be assigned to C2. Note, that the assignment for each topic partition is done independently of other topics, so that if topic T2 also had three partitions, then consumer C1 will still receive the first two partitions in its share.

Round Robin: The partitions from all the topics are sequentially assigned to consumers one by one. Consider the same two consumers and two topics. Say, T1 has 3 partitions and T2 has 2 partitions. The algorithm will assign partition 0 of topic T1 to the first consumer C1, then partition 1 of T1 to C2, then partition 2 of T1 to C1, then partition 0 of T2 to C2 and finally partition 1 of T2 to C1.

We can specify one of the default strategies to use by configuring the partition.assignment.strategy setting. It can be set to either org.apache.kafka.clients.consumer.RangeAssignor or org.apache.kafka.clients.consumer.RoundRobinAssignor. If you want to specify your custom strategy, this setting should be set to your class name.

Popularity 3/10 Helpfulness 1/10 Language whatever
Source: Grepper
Tags: whatever
Link to this answer
Share Copy Link
Contributed on Jun 01 2023
Sumit Rawal
0 Answers  Avg Quality 2/10


X

Continue with Google

By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
X
Grepper Account Login Required

Oops, You will need to install Grepper and log-in to perform this action.