What is Akka Distributed Data (CRDTs)?

Akka Distributed Data is a module in Akka that provides a way to manage eventually consistent, replicated, and distributed data across nodes in a cluster. It is built on the foundation of Conflict-Free Replicated Data Types (CRDTs), which are data structures designed to resolve conflicts automatically when data is updated concurrently on different nodes.

This module is particularly useful in scenarios where strong consistency isn't required, but availability and partition tolerance are critical.

Key Features of Akka Distributed Data :
  1. Eventual Consistency:

    • Updates to data on different nodes are eventually propagated and resolved across the cluster.
  2. Conflict Resolution:

    • CRDTs handle conflict resolution automatically using predefined merge strategies (e.g., merging sets or counters).
  3. High Availability:

    • The data is available for read and write operations even during network partitions.
  4. Scalability:

    • Data is replicated across multiple nodes, and the system scales as the cluster grows.
  5. Distributed State Management:

    • Ideal for scenarios where a shared, distributed state is needed, such as distributed caches, collaborative tools, or leaderboards.
  6. Immutable and Persistent Data:

    • Data changes are propagated as immutable deltas, ensuring safe and consistent replication.
What are CRDTs?

Conflict-Free Replicated Data Types (CRDTs) are special data structures designed for distributed systems. They allow for concurrent updates from multiple nodes and ensure eventual consistency by resolving conflicts automatically without requiring coordination between nodes.

Common CRDT Types in Akka Distributed Data :

  1. Counters:

    • GCounter (Grow-only Counter): Can only be incremented.
    • PNCounter (Positive-Negative Counter): Can be incremented and decremented.
  2. Sets:

    • GSet (Grow-only Set): Allows adding elements but not removing them.
    • ORSet (Observed-Removed Set): Supports adding and removing elements.
  3. Maps:

    • ORMap (Observed-Removed Map): A map of CRDTs that supports adding, updating, and removing entries.
  4. Registers:

    • LWWRegister (Last-Write-Wins Register): Stores a single value with timestamp-based conflict resolution.
  5. Flags:

    • Flag: A boolean flag that can be switched from false to true (one-way toggle).