简体   繁体   中英

Is there a relationship between CRDTs and the RAFT protocol - or are they orthogonal?

Take the use case of a multi-player networked game. Instantly you have the problem of replicating and reconciling shared state across the network.

There appear to be a multiple of tools aimed at aspect of this problem, and two in particular seem to overlap:

  1. Conflict-free Replicated Data Types (CRDTs) - used for
  2. The RAFT consensus algorithm - for choosing a transactional leader in a distributed network to help achieve consensus.

My question is: Is there a relationship between CRDTs and the RAFT protocol - or are they orthogonal?

In distributed systems terms, the two are quite different and serve very different use cases. While both aim to achieve strong consistency, CRDTs do so generally without sacrificing availability, and Raft does so at the expense of availability. In the face of a network partition, CRDTs will remain available, but a Raft cluster can become either partially or fully unavailable. Raft is a consensus algorithm that relies on a majority of the cluster communicating with each other to progress.

There are also differences in the type of state that can be managed by each. CRDTs work to represent a limited and well defined set of data types, while Raft and other consensus algorithms can be used to model a much more wide array of potential data structures and algorithms. Raft is typically used to model a replicated state machine. Commands to the state machine are logged and replicated through the Raft algorithm and applied to a state machine. State machines can be used to model data structures like maps and sets or control concurrency by modeling things like locks, leader elections, and semaphores.

You also have to look at your system in terms of scalability, and Raft and CRTDs differ significant here as well. Raft is a leader-based system. Raft elects a single node as the leader, and all state changes to a Raft replicated state machine go through that single leader and are synchronously replicated to a majority of followers before being applied to the state machine. Alternatively, CRDTs are significantly more scalable as they're not limited by a single node.

Ultimately, the difference between Raft and CRDTs is the difference between consistency and performance. Raft is designed to create a consistent view of a single system with a focus on safety over performance. Typically, consensus algorithms like Raft are used for things like configuration management and service discovery. CRDTs are designed to be fast and as consistent as possible without sacrificing availability. Typically, CRDTs are used for storage in more availability dependent and less critical systems.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM