Graphical kafka consumer two partition allocation strategies

c1 c2 c3
range strategy p0、p1 p2、p3 p4
roundrobin strategy p0、p3 p1、p4 p2

You may think that the two strategies are similar. Both strategies are: two partitions in c1, two partitions in c2, and one partition in c3

Let's look at the situation of multiple TOPICs:

c1 c2 c3
range strategy p1_0、p1_1、p2_0、p2_1 p1_2、p1_3、p2_20、p2_3 p1_4、p2_4
roundrobin strategy p1_0、p1_3、p2_1、p2_4 p1_1、p1_4、p2_2 p1_2、p2_0、p2_3

 Under multiple TOPICs, the two strategies are different.

Under the range strategy: c1 four partitions, c2 four partitions, c3 two partitions

Under the roundrobin strategy: four partitions in c1, three partitions in c2, and three partitions in c3

Range strategy: For multiple topics, divide them by partition and range, and there may be a large difference in the number of partitions between consumers. (default)

roundrobin strategy: Multiple topics are taken as a whole, sorted according to topic + partition, and then distributed to consumers. Misassignments may occur in extreme cases. So kafka's default consumer partition strategy is range.

Guess you like

Origin blog.csdn.net/cakecc2008/article/details/118297892