APP下载

基于HBase的大数据平台负载均衡算法分析与优化

2019-06-07邵芳王勇

软件导刊 2019年1期
关键词:负载均衡大数据预测

邵芳 王勇

摘 要:HBase原有负载均衡算法策略是保证每个Region Server的Region数目相同。但每个Region的访问并不均等,可能造成负载不均衡情况,产生热点数据,影响请求响应效率。部分Region会成为热点,导致一些Region Server负载过重。为提高HBase数据库整体性能,将数据热度因素考虑在内,使用预测方法设计HBase负载均衡算法,把预测数据的热度作为Region Server负载。实验表明,优化后的负载均衡算法可在一定程度上提高HBase数据库性能。

关键词:HBase;大数据;负载均衡;热点数据;预测

DOI:10. 11907/rjdk. 181331

中图分类号:TP312文献标识码:A文章编号:1672-7800(2019)001-0104-04

Abstract: In order to improve the performance of HBase database, the original load balancing algorithm of HBase is analyzed. The original algorithm strategy ensures that the number of Region per Region Server is the same, but because the access of each Region is not equal, it may cause the load imbalance, generate hot data, and affect the response efficiency of the request. Part of the Region will become a hot spot, which some Region Server overload. It is very important to consider the impact of the heat of the data on the load balancing of a distributed database. Therefore, the prediction method is used to design the HBase load balancing algorithm and predict the heat of the data as the load of the Region Server. The experiment shows that the optimized load balancing algorithm can improve the performance of HBase database.

0 引言

隨着互联网的迅猛发展,利用传统关系型数据库解决大规模数据集存在的问题引起广泛关注,NoSQL(Not Only SQL,NoSQL ,非关系型数据库)研究成为热点[1]。互联网产生的数据量增长迅速,对于海量数据的不断增长,要求系统具有良好的横向扩展性,集群技术能够解决此类问题[2]。集群之间能资源共享,控制任务分发调度性能,并且随着数据的增加进行扩展。

Apache HBase是开源分布式NoSQL数据库,HBase技术源于《Bigtable:一个结构化数据的分布式存储系统》这篇Google论文[3]。HBase作为一个分布式列存储数据库,因其高可用性、可扩展性等特征而被广泛应用。HBase和Hadoop无缝集成,利用HDFS实现数据的底层分布式存储[4]。HBase数据库是列式存储的数据库,表的列数可在建表后动态增加,对于无实际值的列不进行存储,节省空间。健康大数据平台使用HBase数据库,负载不均问题直接影响到整个集群的性能。随着大量数据的注入,HBase Region数目的增加或不均等地对Region Server访问[5],HBase通过负载均衡算法保证尽量均等地分配每个Region Server。国内外很多知名企业都使用NoSQL 数据库存储数据,如百度、新浪、Google、腾讯、阿里巴巴、Facebook等[6]。NoSQL数据库相关技术还在不断发展,互联网时代海量数据的应用需求为NoSQL的发展提供了源源不断的动力。因此,对非关系型数据库HBase负载均衡的研究具有重要意义。

1 HBase负载均衡算法分析

如果Region Server存在负载不均衡,那么部分节点的堵塞情况就很容易发生,进而影响整体性能[7]。通过多种措施可以对HBase进行性能调优[8],在0.92版本以后,HBase的负载均衡算法可通过实现了LoadBalancer接口的hbase.master.loadbalancer.class来自定义,实现定制的均衡策略,负载均衡策略是可插拔的。

1.1 SimpleLoadBalancer负载均衡策略分析

在HBase0.94版本中,默认使用SimpleLoadBalancer负载均衡算法,算法步骤是:计算每个Region Server中Region的总数目,用Region总数除以Region Server的数目得到每个Region Server的Region平均数目averageNum,最小值min的值为floor(averageNum),最大值max的值为ceiling(averageNum)[9]。如果所有Region Server都在此范围内,说明不需要进行负载均衡操作。否则,从负载Region数目最大的Region Server开始遍历到负载数目小于等于max为止,把这些需要转移的Region存储起来,设置原地址和目的地址(暂时为空)。从负载Region数目最小的Region Server开始遍历到负载数目大于等于min为止,设置为目的地址。如果仍有负载小于min的Region Server,则从Region数目最多的Region Server中取出一个Region转移到此Region Server中,直到没有负载小于min的Region Server为止。如果仍然存在目的地址为空,则从负载最低的Region Server开始遍历,如果此Region Server负载小于max则将其地址设置为目的地址,直到没有为空的目的地址。若所有目的地址都不为空,则返回。否则,没有目的地址的Region仍放在原Region Server中。

猜你喜欢

负载均衡大数据预测
无可预测
选修2-2期中考试预测卷(A卷)
选修2-2期中考试预测卷(B卷)
异构环境下改进的LATE调度算法