bitwalker / swarm

Easy clustering, registration, and distribution of worker processes for Erlang/Elixir
MIT License
1.2k stars 103 forks source link

topology change when only 1 node available. #108

Closed cburman01 closed 6 years ago

cburman01 commented 6 years ago

@bitwalker What would you suggest is the best way to handle this. When using a 2 node cluster, when 1 of the nodes goes down I would expect the state and processes to move to the other node.

Instead I guest this:

no node available to restart xxxx

I know swarm is pretty much useless with 1 node, but in my case, the cluster could drop to just 1 node.

Thanks for your help.

beardedeagle commented 6 years ago

What strategy are you using?

cburman01 commented 6 years ago

libcluster is:

Elixir.Cluster.Strategy.Epmd,

swarm is:

distribution_strategy: Swarm.Distribution.StaticQuorumRing, static_quorum_size: 2

arjan commented 6 years ago

In that case, try setting the quorum size to 1, if you want to have a functioning "cluster" with one node.

The definition of the quorum size:

It defines the minimum number of nodes that must be connected in the cluster to allow process registration and distribution.

So Swarm's behaviour seems fine to me in this case.

beardedeagle commented 6 years ago

Ah, beat me to it @arjan. As he said, you are getting the expected behavior. You told it you needed 2 nodes to perform any actions, you went below two, so it stops actions from being taken.

Or you can just use the Ring strategy instead.

beardedeagle commented 6 years ago

For more info @cburman01 go here: https://github.com/bitwalker/swarm#swarmdistributionstaticquorumring

cburman01 commented 6 years ago

Thanks @beardedeagle and @arjan! It works exactly as expected now.