Gheorghina Gligor

Thoughts on Coding, Software Architecture, Solving Business Problems, Growing as an Engineer and more importantly, growing as a Leader.

Email address:

CRDT Databases Use Cases

19 Jun 2024 » architecture, CRDT

Introduction

As per CRDT, Conflict-free Replicated Data Type, is a data structure that simplifies distributed data storage systems and multi-user applications.

In many systems, copies of some data need to be stored on multiple computers (known as replicas). In such systems, data may be concurrently modified on different replicas.

Examples of such systems include:

  • Mobile apps that store data on the local device, and that need to sync that data to other devices belonging to the same user (such as calendars, notes, contacts, or reminders);

  • Distributed databases, which maintain multiple replicas of the data (in the same datacenter or in different locations) so that the system continues working correctly if some of the replicas are offline;

  • Collaboration software, such as Google Docs, Trello, Figma, or many others, in which several users can concurrently make changes to the same file or data;

  • Large-scale data storage and processing systems, which replicate data in order to achieve global scalability.

Conflict-free Replicated Data Types (CRDTs) are used in systems with optimistic replication, where they take care of conflict resolution. CRDTs ensure that, no matter what data modifications are made on different replicas, the data can always be merged into a consistent state. This merge is performed automatically by the CRDT, without requiring any special conflict resolution code or user intervention.

Implementations

Implementations for CRDTs can be found here CRDT Implementations

Use Cases

  1. Collaborative Editing

    Example: Google Docs, Microsoft Office 365

    Description: CRDTs are used to enable multiple users to collaboratively edit documents in real-time. They allow users to make changes concurrently, even when offline, and merge these changes seamlessly when they reconnect.

    Benefit: Provides a smooth, real-time collaborative experience with minimal conflicts and no need for a central server to mediate updates.

  2. Messaging and Chat Applications

    Example: Slack, WhatsApp, Microsoft Teams

    Description: In chat applications, CRDTs ensure that messages and updates (like edits or deletions) are consistently replicated across all clients. This is crucial for maintaining a coherent conversation history.

    Benefit: Ensures that all participants see the same message history and state of the chat, even if they were offline or faced network partitions.

  3. Distributed File Systems

    Example: Dropbox, Google Drive

    Description: CRDTs can manage file versions and changes in distributed file systems, allowing users to work offline and sync changes once they reconnect.

    Benefit: Minimizes conflicts and data loss, ensuring that the latest changes are correctly merged and all users have access to the most up-to-date versions of files.

  4. E-Commerce Platforms

    Example: Amazon, eBay

    Description: E-commerce platforms use CRDTs to manage inventory, user carts, and order processing across distributed databases. This ensures consistency in stock levels and user orders across different regions.

    Benefit: Provides a reliable shopping experience by preventing issues like double-selling items or conflicting order states.

  5. Social Media Applications

    Example: Facebook, Twitter

    Description: CRDTs help manage user posts, comments, likes, and other interactions across a distributed environment, ensuring that all users see a consistent view of their social feeds.

    Benefit: Enhances user experience by maintaining consistent interaction states and reducing the impact of network delays or partitions.

  6. IoT and Edge Computing

    Example: Smart home systems, industrial IoT platforms

    Description: CRDTs enable edge devices to operate independently and sync data with the cloud or other devices. This is particularly useful in environments with intermittent connectivity.

    Benefit: Ensures that IoT devices can continue to function and collect data even when disconnected, syncing seamlessly once connectivity is restored.

  7. Gaming

    Example: Multiplayer online games

    Description: CRDTs manage game state, player data, and interactions in real-time, ensuring that all players have a consistent experience despite network latency or interruptions.

    Benefit: Provides a seamless and consistent gaming experience by ensuring that game state and player actions are correctly synchronized across all clients.

Additional References