Search code examples
hazelcast

Configuring specific backup nodes for a Hazelcast Distributed Map?


Imagine that an organization has two data centers (named 'A' and 'B' for simplicity) with multiple nodes running in each, and there is a Hazelcast cluster over all of these nodes. Assume that there is a Distributed Map in this cluster, which is configured to have backup-count of 1.

Is there a way to configure the Hazelcast Distributed Map so that nodes in Data Center A are backed up on the nodes in Data Center B and vice versa? This would mean that the event of losing a single data center the Map data (and backup) is not lost?


Solution

  • what you want is called Partition Grouping. See documentation for details. The simplest thing you can do is to include this snippet in your Hazelcast configuration:

    <partition-group enabled="true" group-type="CUSTOM">
    <member-group>
      <interface>10.10.1.*</interface> <!-- network in data centre A -->
    </member-group>
    <member-group>
      <interface>10.10.2.*</interface> <!-- network in data centre B -->
    </member-group
    </partition-group>
    

    Another option is to create own cluster in each data centre and connect them via WAN replications. This will decrease latencies within the data centre, but it can produce conflicting updates and then it's up to your MergePolicy to deal with it.