This topic provides answers to frequently asked questions about Zookeeper.

What do I do if the ZooKeeper service is unstable and unexpectedly restarts?

The ZooKeeper service may be unstable due to various causes. The most common cause is that the number of ZooKeeper nodes (znodes) or the size of a snapshot is too large. ZooKeeper uses memory to maintain all znodes and synchronizes data between znodes. If the number of znodes or the size of a snapshot is excessively large, the service becomes unstable. ZooKeeper is a distributed coordination service and cannot be used as a file system. We recommend that you keep the number of znodes less than 100,000 and the size of each snapshot less than 800 MB.
  • View the number of znodes on the Status tab of the ZooKeeper service page. Zookeeper-1
  • View the size of snapshots.
    1. On the Configure tab of the ZooKeeper service page, search for the zk_data_dirs parameter and obtain its value. The value indicates the data directory of ZooKeeper. zk_data_dirs
    2. View the size of snapshots in the data directory. snapshot

If the number of znodes or the size of a snapshot is excessively large, check the distribution of znodes. Then, stop upper-layer applications from excessively using ZooKeeper based on the distribution of znodes.

What do I do if an error message that contains "Too many connections" appears?

A possible cause is that the number of connections between each znode and a client IP address exceeds the upper limit.

On the Configure tab of the ZooKeeper service page, search for the maxClientCnxns parameter, which specifies the maximum number of connections between each znode and a client IP address. Then, set the parameter to a larger value based on your business requirements and restart ZooKeeper for the configuration to take effect. Zookeeper-config

If the issue persists after you modify the maxClientCnxns parameter, view the connection metric on the Status tab. If the number of connections continues to increase, check the processes of the ZooKeeper client. For example, check whether all unnecessary connections are closed. After you resolve the issues, the ZooKeeper client can run as expected.