Kafka Consumer Group Coordinator
We could say that there is a loose analogy between these two relationships:
- Consumer Group Coordinator -> Consumer Group
- Controller -> Kafka Cluster
- The Controller monitors the liveness of brokers by keeping a watch on their corresponding ZooKeeper nodes. When a broker that is a leader for a partition goes down, the Controller triggers partition leader election. Which means it elects a new broker to host the leader replica for that partition.
- The Group Coordinator monitors the liveness of consumers of a group, whenever a consumer stops sending heartbeats the Coordinator triggers a partition rebalance. This means that it reassigns the partitions that were consumed by the unresponsive consumer to other consumers of the group.
Admittedly the analogy is not a very strong one. The mechanisms by which they monitor liveness are a bit different as well as the outcomes. In the first case the outcome is a new broker being elected to serve messages from a partition. In the second case it is assigning partitions that belonged to the stopped consumer to be consumed by the other consumers of the group. Also there are multiple Group Coordinators and only one Controller.
Another actor in the kafka cluster that is maybe worth mentioning here is the Transaction Coordinator. Brokers of this type coordinate kafka transactions, each one is assigned to a group of producers but these producers don’t really have to have anything in common with each other unlike the consumers of the Consumer Group Coordinator which all have to belong to the same group.