Skip to content

Raft inside Queen: elections, timings, snapshots

Openraft decides who leads and when an entry is committed. The queue log files are the Raft log, heartbeats run every 100 ms, and a node that was away catches up or loads a snapshot.

Updated View as Markdown

The nodes agree on the log with Raft, through the openraft library. Raft decides who leads and when an entry is committed. An entry is committed when a majority of the nodes has written it and synced it to disk (fsync).

Queen has no separate Raft log: the queue log files are the log (see Storage). The nodes talk on port 7400, over plain HTTP, with a shared token. The leader sends a heartbeat every 100 ms. If the followers hear nothing for one to two seconds, they elect a new leader.

A leader that hears from no majority for 1.5 seconds stops logging new writes and keeps them waiting, in order. After 3 seconds it hands leadership to another node.

Raft's timings in a cluster. The leader sends a heartbeat every 100 milliseconds. Followers that hear nothing for 1 to 2 seconds elect a new leader. A leader that hears from no majority for 1.5 seconds stops logging new writes and keeps them waiting in order; after 3 seconds it hands leadership to another node. A node that was away gets the entries it missed for up to 6 hours, while the leader's disk has room; after that it gets a snapshot, only the part it lacks, exits with code 75 and loads it at start.Raft's timings in a cluster. The leader sends a heartbeat every 100 milliseconds. Followers that hear nothing for 1 to 2 seconds elect a new leader. A leader that hears from no majority for 1.5 seconds stops logging new writes and keeps them waiting in order; after 3 seconds it hands leadership to another node. A node that was away gets the entries it missed for up to 6 hours, while the leader's disk has room; after that it gets a snapshot, only the part it lacks, exits with code 75 and loads it at start.
The timings Raft runs on.

A node that was away gets the entries it missed from the leader, who keeps them for 6 hours while its disk has room. After that, the leader sends a snapshot instead: since 2.6, only the part the node is missing. The node exits with code 75 and loads the snapshot when it starts again.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close