Can talk to Zookeeper but not to the message brokers
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
When building distributed systems, particularly those involving message queuing, both Apache ZooKeeper and message brokers like Apache Kafka play integral roles. Apache ZooKeeper acts as a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services. On the other hand, message brokers like Kafka facilitate sending messages between different applications asynchronously.
Understanding ZooKeeper
ZooKeeper is a centralized service for managing various kinds of configuration and synchronization data. As an analogy, you can think of it like the "nervous system" of your distributed environment. It keeps track of status of the nodes and is also responsible for leader election among distributed processes.
Roles in a distributed system:
- Configuration Management: Store and manage user application configuration.
- Name Service: Provides a hierarchical key-value store.
- Synchronization: Enables coordination and synchronization among distributed applications.
- Group Services: Manages the group dynamics including joining and leaving of nodes.
Understanding Message Brokers
Apache Kafka, a popular message broker, uses ZooKeeper for maintaining its state and metadata. It relies on ZooKeeper for electing leaders among the brokers in a Kafka cluster, tracking broker failures, and notifications about which Kafka broker is alive or not.
Functions of Message Brokers:
- Message Storage: Responsible for retaining messages with fault-tolerance and redundancy.
- Message Routing: Distributes messages across consumers in a balanced and fair manner.
- Scalability and Reliability: Ensures that the system can handle growth in data size and query load.
The Issue: Can Communicate with ZooKeeper but Not Message Brokers
When you find that your application can communicate with ZooKeeper but not with Kafka or another broker, there are several potential issues to explore.
1. Network Configuration
One of the first areas to check is the network configuration. Message brokers like Kafka typically run on different ports and might have different firewall or network rules compared to ZooKeeper.
- Example: Kafka runs by default on port 9092, whereas ZooKeeper might be on port 2181. Ensure both ports are accessible.
2. Broker Configuration
If the message broker configuration isn't correctly pointing to the right ZooKeeper instance, or if the brokers aren't correctly set within the ZooKeeper state, it can lead to communication issues.
- Example: Ensure that
zookeeper.connectin Kafka’sserver.propertiescorrectly points to your ZooKeeper cluster.
3. Client Configuration
The client might be configured to talk to ZooKeeper but not properly set up to communicate with the brokers. This requires correct setting of the bootstrap.servers in Kafka’s client configurations.
- Example: Check that the Kafka client’s
bootstrap.serversproperty includes all brokers’ IP addresses or domain names.
4. Security Settings
Security configurations like SSL/TLS, SASL (Simple Authentication and Security Layer) might differ between how ZooKeeper and Kafka are configured, leading to successful connection with one but not the other.
- Example: Validate the consistency in security settings (like
ssl.keystore.location) between ZooKeeper and the message brokers.
Summary Table
| Issue Category | ZooKeeper | Message Brokers | Common Fixes |
| Network | Port 2181 | Port 9092 | Check firewall and network accessibility |
| Configuration | Managed via zoo.cfg | Managed via server.properties | Ensure cluster setups are pointing correctly |
| Client Setup | Less often directly accessed by apps | Requires correct bootstrap.servers configuration | Validate client configurations |
| Security | Usually internal to services | May be exposed, needing TLS/SSL | Align security configurations |
Conclusion
Understanding the interactions between ZooKeeper and your message brokers is crucial for troubleshooting and ensuring efficient operation of your distributed systems. The key is often in the detail of configurations and ensuring alignment in network and security setups.
Related reading
- Can the same Zookeeper instance be used by number of services?
- can vert.x event bus replace the need for Kafka?
- Can we disable log4j logs only for kafka
- Can we have retention period of zero in Kafka broker?
- Can XOR metric be used to implement DHT without Kademlia?
- Can you find all classes in a package using reflection?
- Can we profile and log a distributed program in elexir?
- Can you catch a native exception in C code?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.