Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't Kafka Producer connect to zookeeper to fetch broker metadata instead of connecting to brokers

Kafka Producers need a bootstrap list of kafka brokers to work. As per this explanation , it needs this to be able to connect to one of the brokers and then fetch metadata about all live brokers in the cluster.

Now, all the brokers are already registered in the Zookeeper and Kafka consumers connect to ZK which handles from which broker , which partition is data to be read from. Why can't Producers also connect to ZK when ZK already has all the information?

I see there are a few SO questions on this but they seem to explain why consumer needs ZK & not why Producer needs bootstrap list of brokers instead of ZK?

like image 437
nikel Avatar asked Mar 01 '16 12:03

nikel


People also ask

Does ZooKeeper interact with producer in Kafka?

The new Producer does not interact directly with ZooKeeper. Producer talks directly to the brokers to publish messages or make meta-data requests to find which broker is the leader for a partition it wants to publish to.

Can we have ZooKeeper and broker in same system?

Zookeeper Servers should not be installed/run on Kafka Broker host.

What is difference between Kafka broker and ZooKeeper?

At a detailed level, ZooKeeper handles the leadership election of Kafka brokers and manages service discovery as well as cluster topology so each broker knows when brokers have entered or exited the cluster, when a broker dies and who the preferred leader node is for a given topic/partition pair.

Do Kafka clients connect to ZooKeeper?

Zookeeper keeps track of status of the Kafka cluster nodes and it also keeps track of Kafka topics, partitions etc. Zookeeper it self is allowing multiple clients to perform simultaneous reads and writes and acts as a shared configuration service within the system.


1 Answers

Both producers and consumers used to connect to Zookeeper for coordination in the past but has now evolved away from that. With the new consumer API in Kafka 0.9 neither of the clients need to know about Zookeeper anymore and this seems to be the future for Kafka clients. Apart from getting rid of dependencies and flaky connection libraries to ZK, it also makes evolution of the client protocol easier since this is now completely managed by Kafka.

Currently both consumer clients are available in Kafka 0.9 but you should be prepared that the consumer client using ZK connectivity will probably become deprecated at some point in a future release.

like image 100
Lundahl Avatar answered Oct 23 '22 15:10

Lundahl