View Source ProcessHub.Strategy.PartitionTolerance.DynamicQuorum (ProcessHub v0.8.0)

The dynamic quorum strategy provides a dynamic way to handle network partitions in the ProcessHub cluster.

This strategy is suitable for clusters that do not know the number of nodes in the cluster beforehand.

The dynamic quorum strategy uses a cache to store the quorum log. The quorum log is a list of tuples containing the node name and the timestamp when the connection to the node was lost. This log is used to calculate the quorum size, which is measured in percentage. If the calculated quorum size is less than the quorum_size defined in the configuration, the ProcessHub will be considered to be in a network partition. In such a case, the ProcessHub will terminate its distributed supervisor process, ProcessHub.DistributedSupervisor, and all its children.

The quorum size is calculated by the following formula:

quorum_size = (connected_nodes / (connected_nodes + down_nodes)) * 100

# The `connected_nodes` are the number of nodes that are currently connected to the `ProcessHub` cluster.
# The `down_nodes` are the number of nodes that are listed under the quorum log.

The threshold_time is used to determine how long a node should be listed in the quorum log before it is removed from the quorum log. This means if we have a threshold_time of 10 seconds, and we lose one node every 10 seconds until we have lost all nodes, the system won't be considered to be in a network partition, regardless of whether the lost nodes are lost due to network partition or not. If we lose all those nodes in less than 10 seconds, the system will be considered to be in a network partition.

Only a node that disappears is logged. A node that drains or whose hub stops was reachable when it went, so any number of nodes can be scaled down that way at once.

Summary

Types

t()

Dynamic quorum strategy configuration.

Types

@type t() :: %ProcessHub.Strategy.PartitionTolerance.DynamicQuorum{
  quorum_size: 51..100,
  startup_nodes: pos_integer() | nil,
  threshold_time: non_neg_integer()
}

Dynamic quorum strategy configuration.

  • quorum_size - The quorum size is measured in percentage, from 51 to 100. For example, 60 means that if we have 10 nodes in the cluster, the system will be considered to be in a network partition if we lose 5 nodes or more within the threshold_time period. With 50 or less two equal halves would both keep running, so the hub refuses to start.
  • threshold_time - The threshold time is measured in seconds. This is how long a node should be listed in the quorum log before it is removed from the quorum log.
  • startup_nodes - Optional. A hub that starts with fewer hub nodes than this stays in partition mode until that many are present, so a node that starts alone does not run as a cluster of one. Default: nil.

Functions

Link to this function

sync_quorum_log(hub, remote_log)

View Source