leader election in zookeeper and Kafka
Asked Answered
B

2

6

a question troubled me a long time. I know the leader election exists in zookeeper. Suppose we have a Kafka cluster connected with Zookeeper ensemble .

So my understanding is like, there is a zookeeper leader in Ensemble, and there are some "partition leaders" in Kafka cluster as well. And Kafka partition leader are elected through Zookeeper API. Is it right ?

Another question, Is master/worker basically same as leader/follower ?

Blacktail answered 26/12, 2016 at 17:58 Comment(0)
N
7
  1. Zookeeper leader election has nothing to to with Kafka partition leader election, vice versa.
  2. Kafka partition leader elect by Controller, Controller is the Broker who registers first in Zookeeper's path /Controller/2,2 is broker.id. When a broker crash down, the leader partition (or leader replica) in this broker will be switched by Controller and Controller will choose one replica in ISR be the partition leader. If this partition offline (all replica not available), this partition cannot be used for write or read. If you set unclean.leader.election.enable=true, then the first available replica will be elected as partition leader, no matter it's in ISR or not. So some messages maybe lost.
  3. Kafka and Zookeeper use leader/follower, not master/worker
Neom answered 21/3, 2017 at 11:32 Comment(0)
M
2

Partition leader election in Kafka is not done through zookeeper API, actually, the first replica in alive assign replicas will be elected as the leader for each partition.

As for the master/worker things, as I know, many open sources have already replaced the old terminology with leader/replica or primary/replica, so basically, they are the same.

Maintenon answered 26/12, 2016 at 23:18 Comment(1)
thanks. Can you provide the links about "he first replica in alive assign replicas will be elected as the leader for each partition." I wanna learn more.Blacktail

© 2022 - 2024 — McMap. All rights reserved.