Skip to main content
Log in

A balanced leader election algorithm based on replica distribution in Kubernetes cluster

  • Published:
Cluster Computing Aims and scope Submit manuscript

Abstract

Kubernetes is a well-known open source project that provides a powerful orchestration platform for containerized applications. To ensure high scalability and availability of services, redundant deployment is usually adopted in Kubernetes clusters, creating multiple replicas for each application. Each replica of a stateful application needs to persistently store data and use a leader-based consistency maintenance mechanism to ensure strong consistency among replicas. In this mechanism, the elected leader is responsible for updating data and synchronizing it to the followers, which results in a higher workload for the leader. When there are multiple stateful applications, the Kubernetes leader election algorithm does not consider the distribution of multiple leaders among nodes, which may lead to the phenomenon of too many leaders on some nodes. This can reduce system performance due to the high workload of the leaders themselves. To address this problem, we propose a balanced leader election algorithm based on replica distribution, which enables multiple stateful application leaders to be evenly distributed among the cluster’s worker nodes. The algorithm effectively solves the problem of system performance degradation caused by leader concentration and achieves load balancing among nodes. We verify the effectiveness of the algorithm through experiments.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6

Similar content being viewed by others

Data Availability

No datasets were generated or analysed during the current study.

References

  1. Wu, Z.: Development and trends of virtualization technology in cloud computing. J. Comput. Appl. 37(4), 915–923 (2017). https://doi.org/10.11772/j.issn.1001-9081.2017.04.0915

    Article  Google Scholar 

  2. Xavier, M.G., Neves, M.V., Rossi, F.D., Ferreto, T.C., Lange, T., De Rose, C.A.F.: Performance evaluation of container-based virtualization for high performance computing environments. In: 2013 21st Euromicro International Conference on Parallel, Distributed, and Network-Based Processing, pp. 233–240 (2013). https://doi.org/10.1109/PDP.2013.41

  3. Bernstein, D.: Containers and cloud: from LXC to docker to Kubernetes. IEEE Cloud Comput. 1(3), 81–84 (2014). https://doi.org/10.1109/MCC.2014.51

    Article  Google Scholar 

  4. Kubernetes Documentation. [Online]. https://kubernetes.io/docs/home/. Accessed 19 Jan 2023

  5. Jiao, Q., Xu, B., Fan, Y.: Design of cloud native application architecture based on Kubernetes. In: 2021 IEEE International Conference on Dependable, Autonomic and Secure Computing, International Conference on Pervasive Intelligence and Computing, International Conference on Cloud and Big Data Computing, International Conference on Cyber Science and Technology Congress (DASC/PiCom/CBDCom/CyberSciTech), pp. 494–499 (2021). https://doi.org/10.1109/DASC-PICom-CBDCom-CyberSciTech52372.2021.00088

  6. Hu, T., Wang, Y.: A Kubernetes autoscaler based on pod replicas prediction. In: 2021 Asia-Pacific Conference on Communications Technology and Computer Science (ACCTCS), pp. 238–241 (2021). https://doi.org/10.1109/ACCTCS52002.2021.00053

  7. Vayghan, L.A., Saied, M.A., Toeroe, M., Khendek, F.: A Kubernetes controller for managing the availability of elastic microservice based stateful applications. J. Syst. Softw. 175, 110924 (2021). https://doi.org/10.1016/j.jss.2021.110924

    Article  Google Scholar 

  8. Nguyen, N., Kim, T.: Toward highly scalable load balancing in Kubernetes clusters. IEEE Commun. Mag. 58(7), 78–83 (2020). https://doi.org/10.1109/MCOM.001.1900660

    Article  Google Scholar 

  9. Simple Leader Election with Kubernetes and Docker. [Online]. https://kubernetes.io/blog/2016/01/simple-leader-election-with-kubernetes/. Accessed 23 Jan 2023

  10. Takahashi, K., Aida, K., Tanjo, T., Sun, I.: A portable load balancer for Kubernetes cluster. In: HPC Asia 2018: Proceedings of the International Conference on High Performance Computing in Asia-Pacific Region, pp. 222–231 (2018). https://doi.org/10.1145/3149457.3149473

  11. Liu, Q., Haihong, E., Song, M.: The design of multi-metric load balancer for Kubernetes. In: 2020 International Conference on Inventive Computation Technologies (ICICT), pp. 1114–1117 (2020). https://doi.org/10.1109/ICICT48043.2020.9112373

  12. Dua, A., Randive, S., Agarwal, A., Kumar, N.: Efficient load balancing to serve heterogeneous requests in clustered systems using Kubernetes. In: 2020 IEEE 17th Annual Consumer Communications & Networking Conference (CCNC), pp. 1–2 (2020). https://doi.org/10.1109/CCNC46108.2020.9045136

  13. Lee, J.-B., Yoo, T.-H., Lee, E.-H., Hwang, B.-H., Ahn, S.-W., Cho, C.-H.: High-performance software load balancer for cloud-native architecture. IEEE Access 9, 123704–123716 (2021). https://doi.org/10.1109/ACCESS.2021.3108801

    Article  Google Scholar 

  14. Wang, Q., Ren, Y., Yang, S., Guan, J., Li, B., Zhang, J., Tan, Y.: ProxyDWRR: a dynamic load balancing approach for heterogeneous-CPU Kubernetes Clusters. In: 2022 IEEE International Conference on Joint Cloud Computing (JCC), pp. 65–72 (2022). https://doi.org/10.1109/JCC56315.2022.00017

  15. Botez, R., Petruti, C.-M., Ivanciu, I.-A., Dobrota, V.: Kubernetes-based load balancer as a service for private cloud infrastructures. In: 2022 14th International Conference on Communications (COMM), pp. 1–6 (2022). https://doi.org/10.1109/COMM54429.2022.9817323

  16. Baresi, L., Hu, D.Y.X., Quattrocchi, G., Terracciano, L.: KOSMOS: vertical and horizontal resource autoscaling for Kubernetes. Serv. Orient. Comput. ICSOC 2021, 821–829 (2021). https://doi.org/10.1007/978-3-030-91431-8_59

    Article  Google Scholar 

  17. Pramesti, A.A., Kistijantoro, A.I.: Autoscaling based on response time prediction for microservice application in Kubernetes. In: 2022 9th International Conference on Advanced Informatics: Concepts, Theory and Applications (ICAICTA), pp. 1–6 (2022). https://doi.org/10.1109/ICAICTA56449.2022.9932943

  18. Kim, T., Choi, S.-G., Myung, J., Lim, C.-G.: Load balancing on distributed datastore in opendaylight SDN controller cluster. In: 2017 IEEE Conference on Network Softwarization (NetSoft), pp. 1–3 (2017). https://doi.org/10.1109/NETSOFT.2017.8004238

  19. Lamport, L.: The part-time parliament. ACM Trans. Comput. Syst. 16(2), 133–169 (1998). https://doi.org/10.1145/3335772.3335939

    Article  Google Scholar 

  20. Ongaro, D., Ousterhout, J.: In search of an understandable consensus algorithm. In: Proceedings of the 2014 USENIX Conference on USENIX Annual Technical Conference, pp. 305–320 (2014). https://www.usenix.org/conference/atc14/technical-sessions/presentation/ongaro

  21. Hunt, P., Konar, M., Junqueira, F.P., Reed, B.C.: ZooKeeper: wait-free coordination for Internet-scale systems. In: USENIX Annual Technical Conference (2010). https://www.usenix.org/legacy/event/atc10/tech/full_papers/Hunt.pdf

  22. Oliveira, C., Lung, L.C., Netto, H., Rech, L.: Evaluating Raft in Docker on Kubernetes. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-48944-5_12

    Book  Google Scholar 

  23. Netto, H., Oliveira, C.P., Oliveira Rech, L., Alchieri, E.: Incorporating the raft consensus protocol in containers managed by Kubernetes: an evaluation. Int. J. Parallel Emerg. Distrib. Syst. 35(4), 433–453 (2020). https://doi.org/10.1080/17445760.2019.1608989

    Article  Google Scholar 

  24. Netto, H., Oliveira, C.P., Oliveira Rech, L., Alchieri, E.: State machine replication in containers managed by Kubernetes. J. Syst. Archit. 73, 53–59 (2017). https://doi.org/10.1016/j.sysarc.2016.12.007

    Article  Google Scholar 

  25. Netto, H.V., Luiz, A.F., Correia, M., Oliveira Rech, L., Oliveira, C.P.: Koordinator: a service approach for replicating docker containers in Kubernetes. In: 2018 IEEE Symposium on Computers and Communications (ISCC), pp. 58–63 (2018). https://doi.org/10.1109/ISCC.2018.8538452

  26. Abdollahi Vayghan, L., Saied, M.A., Toeroe, M., Khendek, F.: Microservice based architecture: towards high-availability for stateful applications with Kubernetes. In: 2019 IEEE 19th International Conference on Software Quality, Reliability and Security (QRS), pp. 176–185 (2019). https://doi.org/10.1109/QRS.2019.00034

  27. SelectorSpreadPriority. [Online]. https://kubernetes.io/docs/reference/scheduling/policies/#priorities. Accessed 23 Jan 2023

  28. Kunpeng server based on arm architecture. [Online]. https://e.huawei.com/cn/products/computing/kunpeng. Accessed 19 Oct 2022

  29. Stateful Applications. [Online]. https://kubernetes.io/docs/tutorials/stateful-application. Accessed 19 Feb 2023

  30. Hey. A tiny program sends some load to a web application. [Online]. https://github.com/rakyll/hey. Accessed 10 Apr 2023

  31. IPVS-based intra-cluster load balancing. [Online]. https://kubernetes.io/zh-cn/blog/2018/07/09/ipvs-based-in-cluster-load-balancing-deep-dive. Accessed 26 Feb 2023

Download references

Acknowledgements

This work is funded by The Key Technology Research and Development Project of Henan Province under Grant 222102210055. Major Science and Technology Special Project of Henan Province, Research and Demonstration of Kunpeng Platform-based Domestic Operating System under Grant 201300210400. Supported by Research on Key technologies of resource scheduling and service High Availability based on ARM architecture, Project No. 232102210199.

Funding

This work was financially supported by Research on Key technologies of resource scheduling and service High Availability based on ARM architecture, Project No. 232102210199.

Author information

Authors and Affiliations

Authors

Contributions

J.L. carries out the conception of experimental ideas and the formulation or evolution of overall research goals and objectives Method design and create models. Y.D. conducted experiments and wrote the main manuscript texts, images and table productions. Y.L. is involved in the analysis of the data and the production of the images. All the authors reviewed the manuscript.

Corresponding author

Correspondence to Junnan Liu.

Ethics declarations

Competing interests

The authors declare no competing interests.

Additional information

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Rights and permissions

Springer Nature or its licensor (e.g. a society or other partner) holds exclusive rights to this article under a publishing agreement with the author(s) or other rightsholder(s); author self-archiving of the accepted manuscript version of this article is solely governed by the terms of such publishing agreement and applicable law.

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Liu, J., Ding, Y. & Liu, Y. A balanced leader election algorithm based on replica distribution in Kubernetes cluster. Cluster Comput (2024). https://doi.org/10.1007/s10586-024-04333-6

Download citation

  • Received:

  • Revised:

  • Accepted:

  • Published:

  • DOI: https://doi.org/10.1007/s10586-024-04333-6

Keywords

Navigation