Leader Election in a Cluster using Zookeeper

  • M. Petrescu Department of Computer Science, Faculty of Mathematics and Computer Science, Babes-Bolyai University, Cluj-Napoca, Romania


This paper presents an algorithm for flexible and fast leader election in distributed systems using Apache Zookeeper for configuration management.

The algorithm proposed in this paper is designed for applications that do not use symmetric nodes so they need a specialized election process or for applications that require a more flexible approach in the leader election process. The algorithm proposes a different approach as it allows assigning prioritizations for servers in the cluster that are candidates to become a leader. The algorithm is flexible as it takes into consideration during the leader election process of the different server settings and roles, network properties, communication latency or specific application requirements.


[1] Artho, C., Banzai, K., Gros, Q., Rousset, G., Ma, L., Kitamura, T., Yamamoto, M., Model based testing of Apache ZooKeeper: Fundamental API usage and watchers. Software Testing, Verification and Reliability, 2019, DOI:10.1002/stvr.1720
[2] Artho C, Gros Q, Rousset G, Banzai K, Ma L, Kitamura T, Hagiya M, Tanabe Y, Yamamoto M. Model-based API testing of Apache ZooKeeper. Proc. 2017 IEEE Int. Conf. on Software Testing, Verification and Validation (ICST 2017): Tokyo, Japan, 2017; pp. 288-298.
[3] Becker D., Junqueira F., Serafini M., Leader Election for Replicated Services Using Application Scores.,2011, DOI 7049. 289-308. 10.1007/978-3-642-25821-3 15.
[4] EL-Sanosi I. ,Ezhilchelvan P., Improving the Latency and Throughput of ZooKeeper Atomic Broadcast, Imperial College Computing Student Workshop, 2018, pp. 3:1–3:10, ISBN 978-3-95977-059-0, DOI 10.4230/OASIcs.ICCSW.2017.3
[5] EL-Sanosi I., Ezhilchelvan P., Improving ZooKeeper Atomic Broadcast Performance by Coin Tossing, Lecture Notes in Computer Science, 2017, pp.249-265. DOI:10.1007/978-3-319-66583-2 16
[6] Ganesan A., Alagappan R., Arpaci-Dusseau A., Arpaci-Dusseau R., Strong and Efficient
Consistency with Consistency-Aware Durability, 18th USENIX Conference on File and Storage Technologies, Santa Clara, CA, 2020, ISBN 978-1-939133-12-0
[7] Hunt P, Konar M, Junqueira F, Reed B. ZooKeeper: Wait-free Coordination for Internet-scale Systems. Proc. USENIX Annual Technical Conf., USENIXATC, USENIX Association: Boston, USA, 2010; 11’11. DOI:
[8] Junqueira F., Reed B. ZooKeeper: Distributed Process Coordination. O’Reilly, 2013, ISBN-13: 978-1449361303
[9] Medeiros A., ZooKeeper’s atomic broadcast protocol: Theory and practice, Helsinki University of Technology, 2012, DOI:
[10] Medeiros A., ZooKeeper’s atomic broadcast protocol: Theory and practice, 2012, retrieved from http://www.tcs.hut.fi/Studies/T-79.5001/reports/2012-deSouzaMedeiros.pdf
[11] Petrescu M., Replication in Raft vs Apache Zookeeper, Advances in Intelligent Systems and Computing, 2020, ISSN 2194-5357
[12] Petrescu M., Petrescu R., Log replication in Raft vs Kafka, Studia Universitas Babes-Bolyai, 2020, DOI 10.24193/subbi.2020.2.05
[13] Santos, N. H., Andre M.S., Latency-aware Leader Election.,2009, DOI 10.1145/1529282.1529513.
[14] ZooKeeper 3.6 Documentation / ZooKeeper Recipes and Solutions, 2020, retrieved from https://zookeeper.apache.org/doc/r3.6.2/recipes.html
[15] ZooKeeper 3.6 Documentation / ZooKeeper Programmer’s Guide, 2020, retrieved from https://zookeeper.apache.org/doc/r3.6.2/zookeeperProgrammers.html
[16] ZooKeeper 3.6 Documentation / The ZooKeeper Data Model, 2020, retrieved from https://zookeeper.apache.org/doc/current/zookeeperProgrammers.html#Ephemeral+Nodes
How to Cite
PETRESCU, M.. Leader Election in a Cluster using Zookeeper. Studia Universitatis Babeș-Bolyai Informatica, [S.l.], v. 66, n. 1, p. 104-115, july 2021. ISSN 2065-9601. Available at: <http://www.cs.ubbcluj.ro/~studia-i/journal/journal/article/view/67>. Date accessed: 03 oct. 2022. doi: https://doi.org/10.24193/subbi.2021.1.07.