Conflict-free replicated data types

The bigger our application becomes, the more data it has to process, even for a single microservice with a well-defined scope. As we mentioned previously, transactions do not scale well, and with application growth, it is harder to keep the global state consistent even within boundaries of one microservice. So, for the sake of performance and system scalability, we may allow data to be updated concurrently by different service instances without a global lock or transactional consistency. Such an approach is called optimistic replication and allows data replicas to evolve in parallel with possible inconsistencies that should be resolved later. In such scenarios, consistency between replicas is re-established when replicas are merged. At that point, conflicts have to be resolved, but this usually means that some changes have to be reverted, which may be unacceptable from a user's standpoint. However, there are also data structures with mathematical properties that ensure the merge process always succeeds. Such data structures are called Conflict-Free Replicated Data Types (CRDT).

CRDT describes data types that can be replicated across multiple computation units, updated concurrently without any coordination, and then merged to get a consistent state. This concept was described by Marc Shapiro, Nuno Preguica, Marek Zawirski, and Carlos Baquero in 2011. At the time of writing, CRDT has a handful of data types, such as a Grow-only Counter, a Grow-only Set, a Two-Phase Set, a Last-Write-Wins-Element Set, and a few other sets that can only cover a subset of typical business workflows. However, CRDT is still proven to be very useful for collaborative text editing, online chats, and online gambling. The SoundCloud audio distribution platform uses CRDT, and a Phoenix web framework employs CRDT to enable real-time multi-node information sharing, while Microsoft's Cosmos DB uses CRDT for writing multi-master data. The Redis database also has built-in support for CRDT in the form of a Conflict-Free Replicated Database (CRDB).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.178.151