An overview of CRDTs

Stefan Alfbo - Nov 5 '23 - - Dev Community

Inspired by the excellent blog post An Interactive Intro to CRDTs, I began to read more about the topic. To solidify my understanding of this concept (which is fairly new, minted around 2011) of CRDTs, I will start with a short overview.

Conflict-free Replicated Data Types (CRDTs) are a family of data types that can be replicated across multiple nodes in a distributed system.

These data types are designed to handle concurrent updates to the same data without conflicts. This makes them ideal for use in a variety of distributed applications, such as real-time collaborative editors, chat systems, and database replicas.

To resolve conflicts the data types are leaning on optimistic replication, which means that replicas can diverge temporarily, and then reconciled later when it is detected that there is a conflict.

CRDTs are not just working in a distributed system it is also working nicely in decentralized system, meaning they do not require a single server. This makes them ideal for use in peer-to-peer networks and other decentralized settings.

There are two approaches of CRDTs:

  • State-based, convergent replicated data types, CvRDTs. This approach is sending the complete state to the other replicas.
  • Operation-based, commutative replicated data types, CmRDTs. This approach is replicating the state by sending the update operation.

Since each approach can simulate the other, they are theoretically equivalent.

There are several known CRDTs which can be seen in my mind map below.

Mind map

I have only have had time to scratch the surface of this concept yet, and the site CRDT.tech is a great starting point for anyone interesting to deep dive in this topic too.

I hope to get time to try to implement something with CRDTs in a near future.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .