View Source ProcessHub.Strategy.Synchronization.Gossip (ProcessHub v0.2.0-alpha)
The Gossip synchronization strategy provides a method for spreading information to other nodes
within the ProcessHub
cluster. It utilizes a gossip protocol to
synchronize the process registry across the cluster.
The Gossip strategy is most suitable for clusters are large. It scales well but produces higher latency than the PubSub strategy when operating in small clusters. When the cluster increases in size, Gossip protocol can also save bandwidth compared to PubSub.
The Gossip strategy works as follows:
- The synchronization process is initiated on a single node.
- The node collects its own local process registry data and appends it to the synchronization data.
- It selects a predefined number of nodes that have not yet added their local registry data.
- The node sends the data to the selected nodes.
- The nodes append their local registry data to the received data and send it to the next nodes.
- When all nodes have added their data to the synchronization data, the message will be sent to nodes that have not yet acknowledged the synchronization ack.
- If node receives the synchronization data which contains all nodes data, it will synchronize the data with it's local process registry and forward the data to the next nodes that have not yet acknowledged the synchronization ack.
- When all nodes in the cluster have acknowledged the synchronization data, the synchronization process is completed and the reference is invalidated.
Each node also adds a timestamp to the synchronization data. This is used to ensure that the synchronization data is not older than the data that is already in the local process registry.
Summary
Types
@type t() :: %ProcessHub.Strategy.Synchronization.Gossip{ recipients: pos_integer(), restricted_init: boolean(), sync_interval: pos_integer() }
The Gossip strategy configuration options.
sync_interval
- The periodic synchronization interval in milliseconds. The default is15000
.recipients
- The number of nodes that will receive the synchronization data and propagate it further. The default is3
.restricted_init
- If set totrue
, the synchronization process will only be started on a single node. This node is selected by sorting the node names alphabetically and selecting the first node. The default istrue
.