计算机科学 ›› 2017, Vol. 44 ›› Issue (10): 165-170.doi: 10.11896/j.issn.1002-137X.2017.10.031

• 软件与数据库技术 • 上一篇    下一篇

基于Bully算法的Redis集群选举方案优化

王芬,顾乃杰,黄增士   

  1. 中国科学技术大学计算机科学与技术学院 合肥230037 中国科学技术大学先进技术研究院 合肥230037,中国科学技术大学计算机科学与技术学院 合肥230037 中国科学技术大学先进技术研究院 合肥230037,中国科学技术大学计算机科学与技术学院 合肥230037 中国科学技术大学先进技术研究院 合肥230037
  • 出版日期:2018-12-01 发布日期:2018-12-01
  • 基金资助:
    本文受安徽省自然科学基金(1408085MKL06),高等学校学科创新引智计划项目(B07033),华为创新研究计划资助

Election Scheme Optimization of Redis Cluster Based on Bully Algorithm

WANG Fen, GU Nai-jie and HUANG Zeng-shi   

  • Online:2018-12-01 Published:2018-12-01

摘要: 随着互联网的迅速发展,用户从系统获取的信息越来越多,访问系统的频率也在迅速增加。当大量客户端访问系统时,请求的响应时间也会大幅增加,传统关系型数据库已经无法满足用户的需求,而内存数据库在保证系统稳定的前提下,改善了用户体验,并得到了越来越广泛的应用。作为NoSQL内存数据库,Redis支持很多数据类型,适用于多种情况下的缓存与存储需求。文中主要介绍Redis集群,它是Redis的分布式实现,支持主从复制,也具有一定的容错性和线性可扩展性,当前使用Redis集群的网站有新浪微博、github等。虽然 Redis集群 应用广泛,但目前它在节点下线后会出现恢复时间长的现象,这与现有Redis集群的选举算法有关,即与Raft算法的实现有关。分析了Redis集群的可靠性,并优化了集群的选举算法。测试结果显示,在单个主节点下线50s内,优化后的集群都能成功恢复,比社区版本的集群提高了40%。

关键词: Redis集群,选举算法,纪元,节点,下线,恢复

Abstract: With the rapid development of Internet,users obtain more and more information from the system,and the frequency of accessing to system also grows rapidly.While a large number of clients access to the system,the response time of the request greatly increases,the traditional relational database is unable to meet the demand of the user,but in-memory database guarantees the stability of system,improves the user experience,and obtains more and more application.As a kind of in-memory database of NoSQL,Redis supports many data types,and it is applicable to many cases of requirements in caching and storage.In this paper,we mainly introduced Redis cluster,which is a distributed implementation of the Redis,supports master-slave replication,has a certain degree of fault tolerance and linear scalability,and recently is used by Sina microblog,github and so on.Although it is widely used,current Redis cluster occasionally has the case that long recovery time is needed after node fails,which has something to do with election algorithm of current Redis cluster,that is the implementation of Raft algorithm.In this paper,we analyzed the reliability of Redis cluster,and optimized the election algorithm of cluster.The results in test show that the optimized cluster can successfully recover in 50 seconds while only one master node is offline,and it is 40% higher than that of the cluster of the community version.

Key words: Redis cluster,Election algorithm,Epoch,Node,Fail,Recovery

[1] CODD E F.Relational database:a practical foundation for productivity[J].Communications of the ACM,1982,25(2):109-117.
[2] SHASHANK T.Professional NoSQL.http://is.muni.cz/publication/1062829.
[3] HAN J,HAIHONG E,LE G,et al.Survey on NoSQL database[C]∥2011 6th International Conference on Pervasive Computing and Applications (ICPCA).IEEE,2011:363-366.
[4] Bradley Joseph Fitzpatrick.memcached.http://memcach-ed.org.
[5] HAN L,LI X.The Implementation of the Redis protocol based on NOSQL database storage.http://www.paper.edu.cn/html/releasepaper/2011/08/519.(in Chinese) 韩利,李昕.基于MySQL数据库存储的 Redis 协议实现.http://www.paper.edu.cn/html/releasepaper/2011/08/519.
[6] GARCIA-MOLINA H,SALEM K.Main memory database systems:An overview[J].IEEE Transactions on Knowledge and Data Engineering,1992,4(6):509-516.
[7] Salvatore Sanfilippo.Redis.http://redis.io.
[8] CATTELL R.Scalable SQL and NoSQL data stores[J].ACM SIGMOD Record,2011,39(4):12-27.
[9] WANG X Y.Memcached and Redis’s application in cache[J].Wireless Internet Technology,2012(9):8-9.(in Chinese) 王心妍.Memcached 和 Redis 在高速缓存方面的应用[J].无线互联科技,2012(9):8-9.
[10] DB-Engines ranking.http://db-engines.com/en.
[11] BEREZECKI M,FRACHTENBERG E,PALECZNY M,et al.Many-core key-value store[C]∥2011 International Green Computing Conference and Workshops (IGCC).IEEE,2011:1-8.
[12] ONGARO D,OUSTERHOUT J.In search of an understandable consensus algorithm[C]∥2014 USENIX Annual Technical Conference (USENIX ATC 14).2014:305-319.
[13] AGRAWAL P.Fault tolerance in multiprocessor systems wi-thout dedicated redundancy[J].IEEE transactions on compu-ters,1988,37(3):358-362.
[14] GARCIA-MOLINA H.Elections in a distributed computingsystem[J].IEEE Transactions on Computers,1982,100(1):48-59.
[15] KORDAFSHARI M S,GHOLIPOUR M,MOSAKHANI M,etal.Modified bully election algorithm in distributed systems[J].WSEAS Transactions on Information Science and Applications,2005,2(8):1189-1194.

No related articles found!
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!