yahoo / CMAK

CMAK is a tool for managing Apache Kafka clusters
Apache License 2.0
11.83k stars 2.51k forks source link

Partition assignment in addPartition #158

Open isimonenko opened 8 years ago

isimonenko commented 8 years ago

I was looking into the way kafka-manager assign partitions during addPartition operation to check if it behaves the same way as with topic creation. Let assume that we have 6 brokers and topic with 9 partitions and replication factor = 2. Data will be distributed not evenly among the brokers:

broker-0  broker-1  broker-2  broker-3  broker-4  broker-5
p0        p1        p2        p3        p4        p5        (1st replica)
p6        p7        p8                                      (1st replica)
p5        p0        p1        p2        p3        p4        (2nd replica)
                    p6        p7        p8                  (2nd replica)

Then we add 3 partitions, and want them to be distributed the following way:

broker-0  broker-1  broker-2  broker-3  broker-4  broker-5
p0        p1        p2        p3        p4        p5        (1st replica)
p6        p7        p8        p9        p10       p11       (1st replica)
p5        p0        p1        p2        p3        p4        (2nd replica)
p10       p11       p6        p7        p8        p9        (2nd replica)

Does current assignment algorithm try to do the same? Seems that not, as for initial shift it gets head of partitionReplicaList which effectively could be random partition.https://github.com/yahoo/kafka-manager/blob/master/app/kafka/manager/utils/AdminUtils.scala#L219 Also, it is not clear what is the idea behind using the same fixedStartIndex if it is specified for both first and second replica shift https://github.com/yahoo/kafka-manager/blob/master/app/kafka/manager/utils/AdminUtils.scala#L75

Even if the assignment doesn't try to behave as I described above, could you explain what is the reason to use id of the first replica of one of the partitions, rather than just use random? Does it improve the distribution of partitions somehow?

patelh commented 8 years ago

I'll try to look at this, this week.

isimonenko commented 8 years ago

hi @patelh have you got a chance to look at it?