当前位置:网站首页>Raft 协议
Raft 协议
2022-07-03 13:33:00 【抓手】
对于强⼀致性共识算法,目前最多使用的就是 Raft 协议。
Raft协议成熟的实现案例
- 蚂蚁金服的JRaft;
- Zookeeper 的 ZAB;
- Consul 的 Raft;
- 百度的 braft;
- Apache 的 Ratis;
Raft角色
- 跟随者(Follower):普通群众,默默接收和来自领导者的消息,当领导者心跳信息超时的时候,就主动站出来,推荐自己当候选人。
- 候选人(Candidate):候选人将向其他节点请求投票 RPC 消息,通知其他节点来投票,如果赢得了大多数投票选票,就晋升当领导者。
- 领导者(Leader):处理写请求、管理日志复制和不断地发送心跳信息(维持领导地位)。
随机超时时间特性
Raft 算法中具有随机超时时间特点,每个节点等待领导者节点心跳信息的超时时间间隔是随机的。为了防止多个节点同时发起投票,每个节点分配的选举超时时间也是随机的。
选举过程
- 初始状态,所有节点都是跟随者。
- 当集群中没有领导者时,等待超时时间最小的节点会因为没有等到领导者心跳信息,发生超时。
- 超时自荐,此时该节点就会增加自己的任期编号,并推举自己为候选人,先给自己投一票,然后向其他节点发送请求投票RPC消息,请它们选举自己为领导者。
- 选举投票,其他节点接受到候选人的RPC消息时,并且在编号为1的任期内,没有投过票,那么就把选票投给该候选人,然后增加自己的任期编号。
- 新领导产生,候选人在选举超时时间内赢得了大多数的选票,那么它就会成为本届任期内新的领导者。
- 正常状态,领导者将周期性地发送心跳消息到其他服务。

边栏推荐
- Qt学习17 对话框及其类型
- 从零开始的基于百度大脑EasyData的多人协同数据标注
- JS continues to explore...
- Toast UI editor (editor allows you to edit your markup document using text or WYSIWYG, with syntax highlighting, scrolling synchronization, real-time preview and chart functions.)
- QT learning 22 layout manager (I)
- QT learning 19 standard dialog box in QT (top)
- MySQL 数据增删改查综合案例
- FPGA测试方法以Mentor工具为例
- Print. JS -- web page file printing
- jvm-运行时数据区
猜你喜欢
![[Jilin University] information sharing of postgraduate entrance examination and re examination](/img/1d/550a991385b842a21e2b301725407e.png)
[Jilin University] information sharing of postgraduate entrance examination and re examination

QT learning 24 layout manager (III)

Ocean CMS vulnerability - search php

Logback log sorting

There is nothing new under the sun. Can the meta universe go higher?
[email protected]纳米粒子"/>金属有机骨架MIL-88负载阿霉素DOX|叶酸修饰UiO-66-NH2负载阿霉素[email protected]纳米粒子

Article content typesetting and code highlighting

Golang - command line tool Cobra

Uio-66-cooh loaded bendamostine | hydroxyapatite (HA) coated MIL-53 (FE) nanoparticles | baicalin loaded manganese based metal organic skeleton material

Global event bus
随机推荐
Uio-66-cooh loaded bendamostine | hydroxyapatite (HA) coated MIL-53 (FE) nanoparticles | baicalin loaded manganese based metal organic skeleton material
Spring cup eight school league
Use and design of Muduo buffer class
28: Chapter 3: develop Passport Service: 11: define attributes in the configuration file, and then obtain them in the code;
Comprehensive case of MySQL data addition, deletion, modification and query
3D视觉——2.人体姿态估计(Pose Estimation)入门——OpenPose含安装、编译、使用(单帧、实时视频)
Formation of mil-100 (FE) coated small molecule aspirin [email protected] (FE) | glycyrrhetinic acid modified metal organ
Halcon combined with C # to detect surface defects -- Halcon routine autobahn
Solve the problem of dormitory router campus network sharing login
Go language unit test 5: go language uses go sqlmock and Gorm to do database query mock
Golang — template
Conversion function and explicit
Solve MySQL 1045 access denied for user 'root' @ 'localhost' (using password: yes)
MySQL 数据处理值增删改
Qt学习23 布局管理器(二)
Go language web development series 26: Gin framework: demonstrates the execution sequence of code when there are multiple middleware
Redis: commandes d'action pour les données de type chaîne
Uniapp skills - scrolling components -1
Golang - command line tool Cobra
Selenium browser (1)