Raft 算法:term 什么时候增加?

Raft algorithm: When will term increase?

Raft divides time into terms of arbitrary length, as shown in Figure 5. Terms are numbered with consecutive integers. Each term begins with an election, in which one or more candidates attempt to become leader as described in Section 5.2. If a candidate wins the election, then it serves as leader for the rest of the term. In some situations an election will result in a split vote. In this case the term will end with no leader; a new term (with a new election) will begin shortly. Raft ensures that there is at most one leader in a given term.

Terms act as a logical clock [14] in Raft, and they allow servers to detect obsolete information such as stale leaders. Each server stores a current term number, which increases monotonically over time.

由此paper,我们知道任期从选举开始,单调递增。

我的问题是什么时候会增加任期?

  1. 超过物理时间会增加吗?例如每分钟,或每小时。

  2. 与逻辑时间有关吗?

  3. 是否只有在新的选举发生时才会增加?

  4. 术语多久更改一次?

  5. 一个学期内会产生多少日志条目?

术语逻辑时间戳,或者在分布式系统中更普遍地称为纪元。术语更改的频率完全取决于节点和网络条件。只有当成员开始新的选举时,任期才会增加。因此,该术语将增加,例如在领导者崩溃后,如果网络分区导致某些成员的选举计时器到期,如果网络中有足够的延迟使选举计时器到期,或者如果选举结束时没有获胜者。