...
Not only the sticky assignor preserves more assignments, it also results in a more balanced assignment.
Example 3
There are two consumers C0, C1, and two topics t0, t1, with 2 partitions each. Therefore, the partitions are t0p0, t0p1,t1p0, t1p1. Both consumers are subscribed to both topics.
The range, round robin, and sticky assignors all result in the following assignment:
Consumer | Assigned Topic Partitions |
---|---|
C0 | t0p0, t1p0 |
C1 | t0p1, t1p1 |
Now, if consumer C2 subscribed to both topics comes on board, the range assignor would produce the following (which is not a fair assignment):
Consumer | Assigned Topic Partitions |
---|---|
C0 | t0p0, t1p0 |
C1 | t0p1, t1p1 |
C2 |
The round robin assignor would produce this (which is not the stickies assignment):
Consumer | Assigned Topic Partitions |
---|---|
C0 | t0p0, t1p1 |
C1 | t0p1 |
C2 | t1p0 |
The sticky assignor would move one of the partitions to the new consumer producing something like this (preserving 3 partition assignments):
Consumer | Assigned Topic Partitions |
---|---|
C0 | t0p0, t1p0 |
C1 | t0p1 |
C2 | t1p1 |
The Algorithm
The inputs to the sticky partition assignment algorithm are
...