Raft in a nutshell: what you need to know about the consensus protocol

submited by
Style Pass
2022-08-06 10:30:06

Raft is a consensus algorithm for managing a replicated log. It is used by MongoDB, CockroachDB, Consul and many other well-known software which uses a distributed system.

In this post, I will do a simple, high-level introduction to Raft consensus protocol. It is supposed to give you an idea of how the protocol works. However, some areas in this post might not be explained in detail intentionally for the sake of simplicity. So, I strongly recommend you to read the article In Search of an Understandable Consensus Algorithm by Diego Ongaro and John Ousterhout which is the whitepaper for the protocol and my main source of information, in order to understand Raft better.

Raft’s main purpose is to enable many servers to act as together. These servers are models of state machines which means that if you define the machine’s current status as a state, then, you may expect an another server with the same state to behave exactly as the other when it is given a command.

State transitions are achieved by commands which are recorded as logs such as “assign 5 to variable x”. Thus, the protocol actually needs to synchronize the logs on different servers.

Leave a Comment