知更鸟是什么鸟| 家有喜事指什么生肖| 马斯卡彭是什么| 定妆喷雾什么时候用| 怀孕前三个月应该注意什么| wdf是什么意思| 调制乳粉是什么意思| 孩子呼吸道感染吃什么药效果最好| 申时五行属什么| 转呼啦圈有什么好处| 站久了脚后跟疼是什么原因| 自主神经功能紊乱吃什么药| 鑫字属于五行属什么| 老是想咳嗽是什么原因| 英语6级是什么水平| 鱼疗是什么鱼| 海南简称是什么| 道听途说什么意思| 百雀羚适合什么年龄段| 12年是什么年| 什么是命| 派特ct主要检查什么| 为什么会出现眼袋| 乌龟吃什么食物| 累觉不爱是什么意思| 风寒水饮是什么意思| 总是心慌是什么原因| 家里有小蜘蛛预示什么| 高处不胜寒的胜是什么意思| 三文鱼刺身是什么意思| logo中文是什么意思| 一直干呕是什么原因| 酒后手麻什么原因| 集中的近义词是什么| 办理健康证需要带什么| 什么什么不断| 96120是什么电话| 属猪的守护神是什么菩萨| 1991年什么命| 什么是气滞| 梦见亲人死了是什么意思| 眉毛淡的男人代表什么| 人体消化道中最长的器官是什么| 肺ca是什么病| vjc是什么品牌| 胃炎吃什么药最有效| 什么是过敏性咳嗽| 56年属什么| 打喷嚏流鼻涕吃什么药好| 为什么会口臭| 手信是什么东西| 小孩脸上长痣是什么原因引起的| 为什么要睡觉| 心率是什么意思| 肠息肉是什么原因造成的| 矬子是什么意思| 屁股疼什么原因| 双字五行属什么| 考试前吃什么提神醒脑| 空调买什么牌子好| 丹参滴丸和丹参片有什么区别| 中国最早的文字是什么| o型血为什么叫贵族血| 大作是什么意思| 胃发胀是什么原因| 九门提督相当于现在什么官| 月经不能吃什么东西| 精油有什么功效| 吉页读什么| 血栓有什么症状| 手不什么什么| 伟五行属性是什么| 痰栓是什么意思| 异淋是什么意思| 铅中毒用什么解毒| 卫冕冠军是什么意思| 减肥吃什么药效果最好| 无机盐包括什么| 五行缺水戴什么| 办理残疾证需要什么材料| 养肺补肺吃什么药最好| 什么是莱赛尔纤维| 阿斗是什么意思| 什么叫哮喘| 献血前需要注意什么| 白细胞数目偏高是什么意思| 凝固是什么意思| 四月28日是什么星座| 右眼皮跳是什么预兆女| 身份证最后四位数代表什么| 百年好合什么意思| 拖是什么意思| 手抖挂什么科| 缺血灶是什么病| 五味子有什么作用| 猴魁属于什么茶| 雷人是什么意思啊| 出现幻觉幻听是什么心理疾病| 血糖高适合喝什么茶| 阳痿早泄是什么原因| 海竹是什么| 神经紊乱吃什么药| 画蛇添足是什么意思| 路虎为什么叫奇瑞路虎| 女人依赖男人说明什么| 大姨妈来的少是什么原因| 四两棉花歇后语是什么| 小龙女叫什么名字| 脓毒血症是什么原因引起的| 蝙蝠是什么动物| 脑供血不足用什么药| 头出汗是什么原因| 猫在风水上代表什么| 魂牵梦萦的意思是什么| 上火了吃什么药好| 今天突然拉稀拉出血什么原因| 子宫内膜厚是什么原因| 中国的四大发明是什么| 炮机是什么| 梦到高考是什么意思| 抗美援朝什么时候结束| 五十坐地能吸土是什么意思| 女生下面什么样| 四川耙耳朵是什么意思| nbr是什么材料| 空调买什么品牌的好| 什么是偏光镜| 63年属什么生肖| 波子是什么车| 康复治疗技术学什么| 什么叫空调病| 封闭针是什么药| 座是什么结构| 淡蓝色配什么颜色好看| 有对什么| 左侧肋骨下面是什么器官| 喝什么茶降血脂| 后代是什么意思| 会车是什么意思| 备孕检查挂什么科| 踢馆什么意思| 子宫下垂是什么症状| 晚上八点多是什么时辰| 非议是什么意思| 寒是什么生肖| 梦见穿破鞋是什么意思| 维生素b12高是什么原因| 活动性肺结核是什么意思| 世界七大奇迹分别是什么| 什么是华人| 立碑有什么讲究和忌讳| 坚果补充什么营养成分| 电解液是什么| 蝉联的意思是什么| 转基因和非转基因有什么区别| 属猴是什么命| 肾结晶是什么病| 心率快是什么原因| 家五行属性是什么| 今年43岁属什么| 生活老师是做什么的| 脚踝疼痛是什么原因| 梦见考试是什么预兆| 吃维e有什么好处和副作用| 后厨打荷是干什么的| 什么是跨境电商| 尿道感染要吃什么药| 肝囊肿是什么意思| 九牧王男装是什么档次| 手指麻木是什么原因| 勺是什么意思| 女孩名字带什么字好听| 蜂蜜和柠檬一起喝有什么作用| 来月经腰疼是什么原因| 跑步什么时候跑最好| 尿比重1.030是什么意思| 耳聋吃什么药| 鸳鸯是什么意思| 舌头疼吃什么药好得快| 什么样的手相最有福气| 谷氨酰基转移酶高是什么原因| 主动脉瓣退行性变是什么意思| 为什么早上起来口苦| 手黄是什么原因| 意义是什么意思| 肾造瘘是什么意思| 点状钙化灶是什么意思| 心口痛挂什么科| 跳蛋是什么| 子宫前倾是什么意思| 11是什么生肖| 手指关节疼痛用什么药| 手机的英文是什么| 蜱虫咬了什么症状| 小孩改姓需要什么手续| 山楂可以和什么一起泡水喝| 手指肿胀什么原因| 尿蛋白阴性是什么意思| 心跳加快吃什么药| 尿酸高说明什么问题| 逸五行属性是什么| 权衡利弊的意思是什么| 529是什么意思| 眼镜轴向是什么意思| 查验是什么意思| 熟的反义词是什么| 二月十号是什么星座| 沁什么意思| 孕妇可以吃什么感冒药| 月亏念什么| 蚁后长什么样| 肩胛骨疼挂什么科| 吃什么东西可以变白| 原研药是什么意思| 什么是零重力座椅| 乘务员是干什么的| 三月18号是什么星座的| 凌霄什么意思| 康熙雍正乾隆是什么关系| 采阴补阳是什么意思| 为什么手指关节会痛| 枸杞与菊花一起泡水喝有什么功效| 是什么品牌| 食管鳞状上皮增生是什么意思| 夏季什么时候最热| 睡觉被口水呛醒是什么原因| 乳房有硬块是什么原因| 荨麻疹不能吃什么食物| 肝疼吃什么药好| 社保卡是什么样的图片| 腮腺炎挂什么科| 婴儿吃手是什么原因| 软笔书法是什么| 吃什么能增加免疫力| 捡肥皂是什么意思| 常青藤是什么意思| 紫玫瑰代表什么意思| 为什么会吐| 什么斗艳| 孕妇为什么要躲着白事| 贡菊泡水喝有什么功效| 夏天煲什么汤| 什么叫高危性行为| 梦见狼是什么预兆| 科技布是什么材质| 灰面是什么面粉| 鸡枞是什么| 彩超能检查什么| 松鼠喜欢吃什么食物| 种牙好还是镶牙好区别是什么| 山代表什么生肖| 尿蛋白低是什么原因| 中华田园犬为什么禁养| 茴香豆是什么豆| 白砂糖是什么糖| 为什么会心肌缺血| 郑板桥擅长画什么| 无力感什么意思| 美国人的祖先是什么人| 脖子粗大是什么原因| 女人缺铁性贫血吃什么好| 种植什么药材最赚钱| 吃什么补肺养肺比较好| 嘴巴长溃疡是什么原因| 百度Jump to content

淄博市版权创意产品亮相第三届“青岛东亚版交会

From Wikipedia, the free encyclopedia
(Redirected from Raft (computer science))
Raft
The Raft consensus algorithm mascot.
ClassConsensus algorithm
百度 更多精彩内容,请关注我们的官方微博和微信公共账号!!!

Raft is a consensus algorithm designed as an alternative to the Paxos family of algorithms. It was meant to be more understandable than Paxos by means of separation of logic, but it is also formally proven safe and offers some additional features.[1] Raft offers a generic way to distribute a state machine across a cluster of computing systems, ensuring that each node in the cluster agrees upon the same series of state transitions. It has a number of open-source reference implementations, with full-specification implementations in Go, C++, Java, and Scala.[2] It is named after Reliable, Replicated, Redundant, And Fault-Tolerant.[3]

Raft is not a Byzantine fault tolerant (BFT) algorithm; the nodes trust the elected leader.[1]

Basics

[edit]

Raft achieves consensus via an elected leader. A server in a raft cluster is either a leader or a follower, and can be a candidate in the precise case of an election (leader unavailable). The leader is responsible for log replication to the followers. It regularly informs the followers of its existence by sending a heartbeat message. Each follower has a timeout (typically between 150 and 300 ms) in which it expects the heartbeat from the leader. The timeout is reset on receiving the heartbeat. If no heartbeat is received the follower changes its status to candidate and starts a leader election.[1][4]

Approach of the consensus problem in Raft

[edit]

Raft implements consensus by a leader approach. The cluster has one and only one elected leader which is fully responsible for managing log replication on the other servers of the cluster. It means that the leader can decide on new entries' placement and establishment of data flow between it and the other servers without consulting other servers. A leader leads until it fails or disconnects, in which case surviving servers elect a new leader.

The consensus problem is decomposed in Raft into two relatively independent subproblems listed down below.

Leader election

[edit]

When the existing leader fails or when the algorithm initializes, a new leader needs to be elected.

In this case, a new term starts in the cluster. A term is an arbitrary period of time on the server for which a new leader needs to be elected. Each term starts with a leader election. If the election is completed successfully (i.e. a single leader is elected) the term keeps going with normal operations orchestrated by the new leader. If the election is a failure, a new term starts, with a new election.

A leader election is started by a candidate server. A server becomes a candidate if it receives no communication by the leader over a period called the election timeout, so it assumes there is no acting leader anymore. It starts the election by increasing the term counter, voting for itself as new leader, and sending a message to all other servers requesting their vote. A server will vote only once per term, on a first-come-first-served basis. If a candidate receives a message from another server with a term number larger than the candidate's current term, then the candidate's election is defeated and the candidate changes into a follower and recognizes the leader as legitimate. If a candidate receives a majority of votes, then it becomes the new leader. If neither happens, e.g., because of a split vote, then a new term starts, and a new election begins.[1]

Raft uses a randomized election timeout to ensure that split vote problems are resolved quickly. This should reduce the chance of a split vote because servers won't become candidates at the same time: a single server will time out, win the election, then become leader and send heartbeat messages to other servers before any of the followers can become candidates.[1]

Log replication

[edit]

The leader is responsible for the log replication. It accepts client requests. Each client request consists of a command to be executed by the replicated state machines in the cluster. After being appended to the leader's log as a new entry, each of the requests is forwarded to the followers as AppendEntries messages. In case of unavailability of the followers, the leader retries AppendEntries messages indefinitely, until the log entry is eventually stored by all of the followers.

Once the leader receives confirmation from half or more of its followers that the entry has been replicated, the leader applies the entry to its local state machine, and the request is considered committed.[1][4] This event also commits all previous entries in the leader's log. Once a follower learns that a log entry is committed, it applies the entry to its local state machine. This ensures consistency of the logs between all the servers through the cluster, ensuring that the safety rule of Log Matching is respected.

In the case of a leader crash, the logs can be left inconsistent, with some logs from the old leader not being fully replicated through the cluster. The new leader will then handle inconsistency by forcing the followers to duplicate its own log. To do so, for each of its followers, the leader will compare its log with the log from the follower, find the last entry where they agree, then delete all the entries coming after this critical entry in the follower log and replace it with its own log entries. This mechanism will restore log consistency in a cluster subject to failures.

Safety

[edit]

Safety rules in Raft

[edit]

Raft guarantees each of these safety properties:

  • Election safety: at most one leader can be elected in a given term.
  • Leader append-only: a leader can only append new entries to its logs (it can neither overwrite nor delete entries).
  • Log matching: if two logs contain an entry with the same index and term, then the logs are identical in all entries up through the given index.
  • Leader completeness: if a log entry is committed in a given term then it will be present in the logs of the leaders since this term.
  • State machine safety: if a server has applied a particular log entry to its state machine, then no other server may apply a different command for the same log.

The first four rules are guaranteed by the details of the algorithm described in the previous section. The State Machine Safety is guaranteed by a restriction on the election process.

State machine safety

[edit]

This rule is ensured by a simple restriction: a candidate can't win an election unless its log contains all committed entries. In order to be elected, a candidate has to contact a majority of the cluster, and given the rules for logs to be committed, it means that every committed entry is going to be present on at least one of the servers the candidates contact.

Raft determines which of two logs (carried by two distinct servers) is more up-to-date by comparing the index term of the last entries in the logs. If the logs have a last entry with different terms, then the log with the later term is more up-to-date. If the logs end with the same term, then whichever log is longer is more up-to-date.

In Raft, the request from a candidate to a voter includes information about the candidate's log. If its own log is more up-to-date than the candidate's log, the voter denies its vote to the candidate. This implementation ensures the State Machine Safety rule.

Follower crashes

[edit]

If a follower crashes, AppendEntries and vote requests sent by other servers will fail. Such failures are handled by the servers trying indefinitely to reach the downed follower. If the follower restarts, the pending requests will complete. If the request has already been taken into account before the failure, the restarted follower will just ignore it.

Timing and availability

[edit]

Timing is critical in Raft to elect and maintain a steady leader over time, in order to have a perfect availability of the cluster. Stability is ensured by respecting the timing requirement of the algorithm:

broadcastTime << electionTimeout << MTBF

  • broadcastTime is the average time it takes a server to send a request to every server in the cluster and receive responses. It is relative to the infrastructure used.
  • MTBF (Mean Time Between Failures) is the average time between failures for a server. It is also relative to the infrastructure.
  • electionTimeout is the same as described in the Leader Election section. It is something the programmer must choose.

Typical numbers for these values can be 0.5 ms to 20 ms for broadcastTime, which implies that the programmer sets the electionTimeout somewhere between 10 ms and 500 ms. It can take several weeks or months between single server failures, which means the values are sufficient for a stable cluster.

Extensions

[edit]

The dissertation “Consensus: Bridging Theory and Practice” by one of the co-authors of the original paper describes extensions to the original algorithm:[5]

  • Pre-Vote: when a member rejoins the cluster, it can depending on timing trigger an election although there is already a leader. To avoid this, pre-vote will first check in with the other members. Avoiding the unnecessary election improves the availability of cluster, therefore this extension is usually present in production implementations.
  • Leadership transfer: a leader that is shutting down orderly can explicitly transfer the leadership to another member. This can be faster than waiting for a timeout. Also, a leader can step down when another member would be a better leader, for example when that member is on a faster machine.

Production use of Raft

[edit]
  • CockroachDB uses Raft in the Replication Layer.[6]
  • Etcd uses Raft to manage a highly-available replicated log [7]
  • Hazelcast uses Raft to provide its CP Subsystem, a strongly consistent layer for distributed data structures. [8]
  • MongoDB uses a variant of Raft in the replication set.
  • Neo4j uses Raft to ensure consistency and safety. [9]
  • RabbitMQ uses Raft to implement durable, replicated FIFO queues. [10]
  • ScyllaDB uses Raft for metadata (schema and topology changes) [11]
  • Splunk Enterprise uses Raft in a Search Head Cluster (SHC) [12]
  • TiDB uses Raft with the storage engine TiKV.[13]
  • YugabyteDB uses Raft in the DocDB Replication [14]
  • ClickHouse uses Raft for in-house implementation of ZooKeeper-like service [15]
  • Redpanda uses the Raft consensus algorithm for data replication [16]
  • Apache Kafka Raft (KRaft) uses Raft for metadata management.[17]
  • NATS Messaging uses the Raft consensus algorithm for Jetstream cluster management and data replication [18]
  • Camunda uses the Raft consensus algorithm for data replication [19]

References

[edit]
  1. ^ a b c d e f Ongaro, Diego; Ousterhout, John (2013). "In Search of an Understandable Consensus Algorithm" (PDF).
  2. ^ "Raft Consensus Algorithm". 2014.
  3. ^ Why the "Raft" name?
  4. ^ a b Ben B. Johnson. "Raft: Understandable Distributed Consensus". The Secret Lives of Data website. Retrieved August 4, 2021.
  5. ^ "CONSENSUS: BRIDGING THEORY AND PRACTICE" (PDF).
  6. ^ "Replication Layer | CockroachDB Docs". www.cockroachlabs.com. Retrieved 2025-08-14.
  7. ^ "Raft README". github.com. Retrieved 2025-08-14.
  8. ^ "CP Subsystem". docs.hazelcast.com. Retrieved 2025-08-14.
  9. ^ "Leadership, routing and load balancing - Operations Manual". Neo4j Graph Data Platform. Retrieved 2025-08-14.
  10. ^ "Quorum Queues". RabbitMQ. Retrieved 2025-08-14.
  11. ^ "ScyllaDB's Path to Strong Consistency: A New Milestone". 4 May 2023.
  12. ^ "Handle Raft issues". Splunk. 2025-08-14. Retrieved 2025-08-14.
  13. ^ "Raft and High Availability". PingCAP. 2025-08-14. Retrieved 2025-08-14.
  14. ^ "Replication | YugabyteDB Docs". www.yugabyte.com. Retrieved 2025-08-14.
  15. ^ "ClickHouse Keeper". clickhouse.com. Retrieved 2025-08-14.
  16. ^ "Raft consensus algorithm".
  17. ^ "KRaft Overview | Confluent Documentation". docs.confluent.io. Retrieved 2025-08-14.
  18. ^ "JetStream Clustering".
  19. ^ "Raft consensus and replication protocol".
[edit]
阑尾是什么 岁寒三友是指什么 糖类抗原是检查什么的 乳腺癌多发于什么年龄 oc是什么意思
非钙化斑块是什么意思 ckmb是什么意思 1037年属什么生肖 欣字取名什么寓意 姑姑叫我什么
酒后头疼吃什么药 4月20号是什么星座 七月二十五是什么星座 吃什么能养肝护肝 水痘什么样
目敢念什么 牙碜是什么意思 睡觉盗汗是什么原因 善哉善哉是什么意思 欲壑难填是什么意思
什么水果热量低hcv9jop8ns0r.cn 85属什么生肖hcv7jop4ns6r.cn 军校是干什么的hcv8jop2ns4r.cn 参事是什么级别hcv9jop7ns3r.cn 双响炮是什么hkuteam.com
肺气阴两虚吃什么中成药hcv9jop5ns0r.cn 冬虫夏草有什么功效与作用hcv7jop4ns7r.cn 弥漫是什么意思hkuteam.com 着痹是什么意思hcv8jop9ns3r.cn 武则天墓为什么不敢挖hcv8jop6ns4r.cn
什么的海风hcv9jop4ns8r.cn 心下痞是什么意思hcv8jop2ns7r.cn 什么的食物hcv7jop5ns2r.cn 蟑螂卵什么样hcv8jop8ns2r.cn 复诊是什么意思hcv9jop8ns0r.cn
三国是什么朝代hcv8jop6ns4r.cn pp是什么意思xinjiangjialails.com 新生儿超敏c反应蛋白高说明什么hcv9jop3ns9r.cn 我不知道你在说什么英文hcv8jop4ns2r.cn 生理期为什么会肚子疼hcv9jop0ns1r.cn
百度