David Jacot created KAFKA-21638:
-----------------------------------
Summary: Range v2: make the range assignor sticky
Key: KAFKA-21638
URL: https://issues.apache.org/jira/browse/KAFKA-21638
Project: Kafka
Issue Type: Bug
Reporter: David Jacot
Assignee: David Jacot
The range assignor, the server-side assignor of consumer groups (KIP-848) that
keeps co-partitioned topics together, computes every assignment from scratch.
It sorts the members and cuts every topic into consecutive ranges in that
order. When a member joins or leaves, the ranges of the other members shift, so
partitions move between members that did not change.
For example, take three members A, B and C subscribed to a topic T of twelve
partitions, and a fourth member D that joins:
||Member||Before||Range assignor, after D joins||Moving only what D needs||
|A|T-0, T-1, T-2, T-3|T-0, T-1, T-2|T-0, T-1, T-2|
|B|T-4, T-5, T-6, T-7|T-3, T-4, T-5|T-4, T-5, T-6|
|C|T-8, T-9, T-10, T-11|T-6, T-7, T-8|T-8, T-9, T-10|
|D| |T-9, T-10, T-11|T-3, T-7, T-11|
D needs three partitions. The range assignor moves six: T-3 goes from A to B,
and T-6 and T-7 from B to C, although neither B nor C changed. Every
co-partitioned topic moves the same way. With 30 members and a topic of 1,200
partitions, a join moves about 430 partitions where 38 are enough, and a
rolling restart of the group moves every partition several times. Every moved
partition is revoked from a member that is consuming it, which commits its
offsets and gives up its state, and is then fetched again by another member.
The range assignor also gives the extra partitions of every topic, those left
when its partitions do not divide evenly, to the first members in its order.
With three members and topics of 4, 5, 7, 8, 10 and 11 partitions, the members
get 18, 15 and 12 partitions where 15 each is possible. Finally, it ignores
racks, where the client-side range assignor aligns partitions with the racks of
the consumers, and it builds a new assignment for every member on every run,
even when nothing changes.
The goal is a new version of the range assignor, meant to replace it, with
these properties in priority order:
# *Validity*: every partition of every subscribed topic goes to exactly one of
its subscribers.
# *Spread*: every subscriber of a topic gets the same number of its partitions,
or one more.
# *Co-partitioning*: topics with the same subscribers and the same number of
partitions are assigned together. Every member gets the same partitions of all
of them, as with the range assignor today.
# *Balance*: the extra partitions are spread over the members instead of going
to the first ones, as far as co-partitioning allows.
# *Rack alignment*, when enabled: as many partitions as possible go to a member
in a rack holding one of their replicas, without breaking the properties above.
# *Stickiness*: partitions move only when the properties above require it, and
an assignment that already has them stays unchanged. A join moves about what
the joiner gets, and a leave about what the leaver had.
# *Determinism*: the assignment only depends on the group and its topics, not
on the order in which they are given.
The new version reuses the uniform assignor v2 (KAFKA-21163): topics with the
same subscribers and the same number of partitions form a group, which is
assigned as the uniform assignor v2 assigns a topic.
The spread and the co-partitioning are those of the range assignor today. What
a group gives up is the consecutive ranges: after a member joins or leaves, the
partitions of a member can have gaps.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)