Sharing data between nodes in an Akka cluster
Another interesting task you can accomplish through an Akka cluster is to have distributed data across all the nodes. The distributed data module allows you to use Conflict-Free Replicated Data Types (CRDTs) to have eventually consistent data structures. CRDTs permit you to execute updates from any node without coordination. In the case of update collision, the algorithm uses a monotonic merge function to resolve the issue.
This data is spread across cluster nodes via replication, and all the updates to these data structures are advertised by a Gossip protocol. The idea behind using Gossip is that all members should converge and decide the current state of a given data structure. By default, the Akka distributed data module provides the following data structures; however, it is possible to create your own custom ReplicatedData
types:
- Counters:
GCounter
andPNCounter
- Sets:
GSet
andORSet
- Maps:
ORMap
,ORMultiMap
,LWWMap
, andPNCounterMap
- Registers...