liveBook · Manning

Group leader

As explained in Apache Kafka in Action

A group leader is the first consumer to join a consumer group and the member responsible for creating its partition distribution plan.

When consumers in a Kafka consumer group divide partitions, one consumer creates the distribution plan. The first consumer to join becomes the group leader. During a rebalance, it determines which member gets each partition and sends the plan to the group coordinator, a broker. The coordinator relays the assignments; members can then resume consuming from their assigned partitions. section 9.4.1 section 9.4.2

Figure 9.4 The Kafka Rebalance Protocol allows a group to distribute certain resources among its members, for example, consumer partitions. In this process, a broker acts as the group coordinator, and one of the consumers serves as the group leader.
A screenshot of a computer screen

AI-generated content may be incorrect.

The rebalance diagram distinguishes the consumer acting as group leader from the broker acting as group coordinator. section 9.4.1

Assigning two topics

With the default Range Assignor, two topics with two partitions each and three consumers place partition 0 of both topics on one consumer and partition 1 of both on another. The third consumer receives no partitions. This arrangement can help when corresponding partitions of two topics need to be processed together, but it does not use every available consumer. section 9.4.2

The leader applies the group's partition assignment strategy; it does not replace the coordinator. Configure the strategy with partition.assignment.strategy, and keep it the same across all consumers in the group. Mixed strategies can make assignments unpredictable and cause processing inconsistencies or performance problems. section 9.4.2

How Apache Kafka in Action covers it

How deep it goes
Traces leader selection and the assignment handoff through the group coordinator, then explains assignment strategies without detailing leader implementation.
Examples
Illustrates Range assignment with two two-partition topics and three consumers, leaving one consumer without partitions.
What it assumes
Assumes familiarity with Kafka consumers, topics, and partitions while explaining how leader and coordinator responsibilities differ.
What you can do after
Operate/configure it by keeping partition assignment strategies consistent across group members and interpreting the leader’s role during rebalances.
How it connects
Connects the group leader to consumer groups, group coordinators, rebalances, partition assignment strategies, and the Range Assignor.

Also explained in

Compare how 2 books explain group leader →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Apache Kafka in Action. The section links point to the parts of the book it draws on.