当前位置:网站首页>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的任期内,没有投过票,那么就把选票投给该候选人,然后增加自己的任期编号。
- 新领导产生,候选人在选举超时时间内赢得了大多数的选票,那么它就会成为本届任期内新的领导者。
- 正常状态,领导者将周期性地发送心跳消息到其他服务。
边栏推荐
- Rasp implementation of PHP
- jvm-类加载
- 金属有机骨架(MOFs)抗肿瘤药载体|PCN-223装载甲硝唑|UiO-66包载盐酸环丙沙星([email protected])
- Redis: redis data structure and key operation commands
- MySQL 数据增删改查综合案例
- GoLand 2021.2 configure go (go1.17.6)
- Go language web development series 29: Gin framework uses gin contrib / sessions library to manage sessions (based on cookies)
- Record 405 questions about bank callback post request
- Vite project commissioning
- Go language web development series 28: solve cross domain access of CORS with gin contrib / CORS
猜你喜欢
Configure stylelint
FPGA test method takes mentor tool as an example
Redis: redis data structure and key operation commands
Using registered classes to realize specific type matching function template
Global event bus
[understanding by chance-37]: the structure of human sensory system determines that human beings are self-centered
MySQL 数据处理值增删改
[email protected] (FE) | glycyrrhetinic acid modified metal organ"/>
Formation of mil-100 (FE) coated small molecule aspirin [email protected] (FE) | glycyrrhetinic acid modified metal organ
The small project (servlet+jsp+mysql+el+jstl) completes a servlet with login function, with the operation of adding, deleting, modifying and querying. Realize login authentication, prevent illegal log
Installation impression notes
随机推荐
Collection of mobile adaptation related articles
Common plug-ins for vite project development
核酸修饰的金属有机框架药物载体|PCN-223金属有机骨架包载Ad金刚烷|ZIF-8包裹阿霉素(DOX)
jvm-运行时数据区
Go language unit test 5: go language uses go sqlmock and Gorm to do database query mock
Nucleic acid modified metal organic framework drug carrier | pcn-223 metal organic framework encapsulated ad adamantane | zif-8 encapsulated adriamycin (DOX)
FPGA test method takes mentor tool as an example
Go language web development series 27: Gin framework: using gin swagger to implement interface documents
[combinatorics] permutation and combination (examples of combinatorial number of multiple sets | three counting models | selection problem | combinatorial problem of multiple sets | nonnegative intege
Selenium browser (1)
Qt学习19 Qt 中的标准对话框(上)
[technology development-24]: characteristics of existing IOT communication technology
QT learning 25 layout manager (4)
PHP maze game
MySQL 数据处理值增删改
GoLand 2021.1: rename the go project
PhpMyAdmin stage file contains analysis traceability
Conversion function and explicit
Redis: redis data structure and key operation commands
JS new challenges