Bootstrap server vs zookeeper in kafka?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Apache Kafka, a popular distributed streaming platform, requires robust management for both metadata and group coordination to ensure reliable data streaming. Two significant components often discussed in the context of Kafka are the Bootstrap server and ZooKeeper. Although they serve different purposes, understanding their functions and interactions is crucial for effectively managing a Kafka cluster.
What is a Bootstrap Server?
The Bootstrap server in Kafka is essentially an entry point for Kafka clients (producers and consumers) to interact with the Kafka cluster. When a Kafka client wants to send or receive messages, it needs to connect to the Kafka cluster. Since Kafka is designed to run on multiple servers (known as brokers), the client needs a way to initially connect to the cluster. This is where the Bootstrap server comes into play.
A Bootstrap server is simply one or more of the Kafka brokers specified in the client's configuration. The client only needs the IP address and port of any Kafka broker in the cluster. Once the connection is established, the client will retrieve metadata about other brokers and topics from the connected broker. This metadata includes information about which broker holds which partitions and the leaders for each partition.
Example of Setting Up a Bootstrap Server
In the Kafka client configuration, you specify the bootstrap server as follows:
Here, 192.168.99.100:9092 and 192.168.99.101:9092 are the IP addresses and ports of the brokers that can be used by the client to connect to the Kafka cluster.
What is ZooKeeper?
ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services. In the context of Kafka, ZooKeeper is used to manage and coordinate the Kafka brokers.
ZooKeeper maintains a structure similar to a filesystem, which keeps track of status of the Kafka cluster nodes and Kafka topics, partitions etc. It also keeps track of Kafka topics, partitions, and configurations.
Functions of ZooKeeper in Kafka:
- Broker Registration: When a new broker is started, it registers itself with ZooKeeper. ZooKeeper maintains a list of all active brokers in the cluster.
- Cluster Topology: ZooKeeper notifies Kafka about changes in the cluster, such as brokers going down or new ones coming up.
- Leader Election for Partitions: ZooKeeper helps in electing a leader for each partition. If the current leader fails, ZooKeeper can facilitate the election of a new leader.
Example of ZooKeeper in Action
When a broker starts, it registers itself with a ZooKeeper path like /brokers/ids/1. Consumers and producers can query ZooKeeper to get the list of active brokers.
Key Differences Summarized
| Aspect | Bootstrap Server | ZooKeeper |
| Function | Initial connection point for clients | Coordination and management of the Kafka cluster |
| Role in Kafka | Provides metadata about brokers and topics to the clients | Manages cluster state, leader election, and configurations |
| Configuration | Specified in client's config (bootstrap.servers) | Integrated into Kafka brokers and used internally |
| Dependency | Required for clients to send/receive messages | Required by brokers for cluster management |
Conclusion
The roles of Bootstrap servers and ZooKeeper in Kafka complement each other. While Bootstrap servers facilitate initial client connections by providing necessary metadata about brokers and topics, ZooKeeper manages the overall cluster's health and configuration. Understanding these components is pivotal for deploying, managing, and scaling Kafka effectively.

