Raft Consensus Algorithm

The Raft consensus algorithm is a computer algorithm that distributes a state machine across a cluster of computer systems. It ensures that each node in the cluster agrees upon the same series of state transitions even in the face of failures. The algorithm was designed as a more easily understood alternative to the Paxos protocols for failure resolution. It has open source reference implementations such as C++, Java, and Scala.

What is consensus

Consensus is the process of getting multiple servers to agree on a specific value based on the votes of each server. Once a decision has been made on a value, the decision is final. The value decided upon must be submitted by a server, meaning the consensus algorithm cannot devise a value on its own. Most simply, the value may be 0 or 1, allowing all servers to make a decision on whether to do something or not. Consensus is used in the context of replicated state machines, a mathematical model of computation.

How Raft works

Raft functions by electing a leader in the cluster. A server in a cluster is either a leader or a follower, and can possibly be a candidate if the leader is unavailable. The leader manages the replication of the log to other servers and accepts client requests. A leader leads until it fails or disconnects, in which case a new leader is chosen from the candidates. Data flows in one direction: from the leader to other servers.

Raft decomposes consensus into three independent sub-problems:

  • Leader election: When the current leader fails, a new leader needs to be elected.
  • Log replication: Through replication, the leader needs to keep its own server in sync with the logs of all other servers.
  • Safety: No other server can apply for a log entry at a particular index if a server has already committed to a log entry for that index. This is to ensure logs are consistent and state machined execute the same set of commands.

Raft can be used for replication in distributed systems. It builds strong and consistent systems without sacrificing performance or accuracy. Distributed databases such as TiDB and YugabyteDB use Raft for leader election and data replication for NewSQL database management.

Abby Braden
Abby Braden
Abby Braden is an award-winning writer and editor for websites such as TechnologyAdvice.com, Webopedia.com, and Project-Management.com, where she covers technology trends and enterprise and SMB project management platforms. When she’s not writing about technology, she enjoys giving too many treats to her dog and coaching part-time at her local gym.
Get the Free Newsletter
Subscribe to Daily Tech Insider for top news, trends & analysis
This email address is invalid.
Get the Free Newsletter
Subscribe to Daily Tech Insider for top news, trends & analysis
This email address is invalid.

Related Articles

Complete List of Cybersecurity Acronyms

Cybersecurity news and best practices are full of acronyms and abbreviations. Without understanding what each one means, it's difficult to comprehend the significance of...

Human Resources Management System

A Human Resources Management System (HRMS) is a software application that supports many functions of a company's Human Resources department, including benefits administration, payroll,...

How To Defend Yourself Against Identity Theft

Almost every worldwide government agency responsible for identity theft issues will tell you the same thing: The first step to fighting identity theft is...

Infographic

An infographic is a visual representation of information or data. It combines the words information and graphic and includes a collection of imagery, charts,...

ScalaHosting

ScalaHosting is a leading managed hosting provider that offers secure, scalable, and affordable...

HRIS

Human resources information system (HRIS) solutions help businesses manage multiple facets of their...

Best Managed Service Providers...

In today's business world, managed services are more critical than ever. They can...