• 中国计算机学会会刊
  • 中国科技核心期刊
  • 中文核心期刊

计算机工程与科学 ›› 2020, Vol. 42 ›› Issue (08): 1339-1344.

• 高性能计算 • 上一篇    下一篇

基于动态权重的一致性哈希微服务负载均衡优化

张开琦1,刘晓燕1,王信1,吉春山2,严馨1   

  1. (1.昆明理工大学信息工程与自动化学院,云南 昆明 650500;2.金川镍钻研究设计院,甘肃 金昌 737100)

  • 收稿日期:2020-01-09 修回日期:2020-04-16 接受日期:2020-08-25 出版日期:2020-08-25 发布日期:2020-08-29
  • 基金资助:
    国家自然科学基金(61462055)

Load balancing optimization of consistent hashing  microservice based on dynamic weight

ZHANG Kai-qi1,LIU Xiao-yan1,WANG Xin1,JI Chun-shan2,YAN Xin1   

  1. (1.Faculty of Information Engineering and Automation,Kunming University of Science and Technology,Kunming 650500;

    2.Jinchuan Nickel Drill Research and Design Institute,Jinchang 737110,China)

  • Received:2020-01-09 Revised:2020-04-16 Accepted:2020-08-25 Online:2020-08-25 Published:2020-08-29

摘要: 随着互联网技术的发展,互联网服务器集群的负载能力正在面临着前所未有的挑战,实现合理的负载均衡策略尤为重要。为了使负载均衡达到最佳的效率,可以使用一致性哈希算法来对集群负载均衡系统进行负载分配。针对微服务架构的服务器集群场景,对该集群负载均衡的特性进行分析,提出一种基于虚拟节点的一致性哈希环的设计与分割方法及基于动态权值的分配策略,在一致性哈希算法的基础上,实现服务集群之间的负载转移,解决微服务集群中服务负载增多,导致服务之间负载不均衡的问题,防止其中某些服务因为负载压力过大,导致服务崩溃的问题。经实验表明,与传统的一致性哈希算法相比,改进后的负载均衡策略负载不均衡的概率是原来的31%;并且动态分配策略具有良好的负载均衡性能,有效地解决了微服务分布式架构的负载均衡问题。


关键词: 微服务, 一致性哈希, 负载均衡, 动态权值

Abstract: With the development of Internet technology, the load capacity of Internet server clusters is facing unprecedented challenges, and it is particularly important to implement a reasonable load balancing strategy. In order to achieve the best efficiency for load balancing, a consistent hash algorithm is adopted to distribute the loads of the load balancing system into a cluster. This paper analyzes the characteristics of load balancing in a cluster of servers based on microservice architecture, and proposes a method for designing and segmenting a consistent hash ring based on virtual nodes and a dynamic weight-based allocation strategy. Based on the consistent hash algorithm, load transfer between service clusters is achieved to solve the problem of load imbalance between services caused by increased service load in microservice clusters. It can prevent some services from crashing due to excessive load pressure. The experiments show that the improved load balancing strategy only has 31% load imbalance probability of the traditional consistency algorithm, and the dynamic allocation strategy has good load balancing performance, and can effectively solve the load balancing problem of microservices distributed architecture.

Key words: microservice, consistent hashing, load balancing, dynamic weight