-
Fully Connected Cluster
Because it depends on
global
's name registration service. The name server must maintains a fully connected network.For example, if node N1 connects to node N2 (which is already connected to N3), the global name servers on the nodes N1 and N3 ensure that also N1 and N3 are connected. In other words, command-line flag
-connect_all false
can not be used. -
Same Global Configuration
All node's
global_quorum_size
andglobal_jobs
must keep the same value. This ensures that the global task manager can transfer between nodes when the network splits.
-
global_jobs
the same format as
local_jobs
, default is[]
. This means only run local jobs without running global task manager and monitor processes. -
global_quorum_size
ecron application live on at least
global_quorum_size
nodes in the same cluster, can be regarded as a healthy cluster.Global task manager only running on a healthy cluster.
If you want to guarantee always no more than one global task manager even when the cluster has network split, you should set it to "half plus one". For example:
Run on majority:
ABC
3 nodes in one cluster.global_quorum_size=2
.- (
ABC
) cluster split into 2 part(AB
=|=C
). - the global task manager would run on
AB
cluster(AB
is the healthy cluster now). C
node only running local jobs without global jobs.
Run on majority
ABC
3 nodes in one cluster.global_quorum_size=2
.- (
ABC
) cluster split into 3 part(A
=|=B
=|=C
). - every node only running local jobs without global jobs(all nodes is unhealthy).
Run on every node if brain split.
ABC
nodes in one cluster.global_quorum_size=1
.- (
ABC
) cluster split into 3 part(A
=|=B
=|=C
). - the global task manager would run on every nodes(we have three healthy cluster now).
- But the global task manager only running one in the same cluster.
- The top supervisor
ecron_sup
start at first. - Nothing will happen if the
global_jobs
is empty. ecron_sup
would start_linkecron_monitor
worker (gen_server) ifglobal_jobs
is not empty.ecron_monitor
subscribes node's up/down messages by net_kernel:monitor_nodes(true), when it initializes.- Enter
ecron_monitor
main loop:- Checking if there is enough
ecron
process in the cluster(global_quorum_size
). - Trying to terminate global_job manager process when cluster's
ecron
number less thanglobal_quorum_size
. - Otherwise, trying to start a global_job manager process, This gen_server register by global:register_name/2.
- All the nodes are rushing to register this global jobs manager process, only one node will success, other node's
ecron_monitor
would link this process if the process already exists. - The
ecron_monitor
should receive notification, when node down/up or the global_job manager has terminated. - Goto step 5 again, When notified.
- Checking if there is enough
NodeA NodeB NodeC
supervisor supervisor supervisor
| | | |
monitor monitor | monitor
\ | | /
\ [link] | /
\ | | /
[link]-----GlobalJob-----[link]
NodeB has won the race and spawn global manager process, other node's ecron_monitor
only link to this manager.