In Rachis every cluster node has a state and a type.
The type defines the node's ability to vote on accepting a new raft command in the cluster,
and elect a new leader when needed.
||A fully functional voting node in the cluster.
||A non-voting node.
This is an intermediate stage until node is promoted by the Leader to a Member.
||A non-voting node that is still fully managed by the cluster.
Can be assigned with databases and tasks. See more below.
The Rachis state defines the current role of the node in the cluster.
||Not a part of any cluster.
Every newly created RavenDB server starts at the initial Passive state.
A passive node can become a Leader of a single-node-cluster,
or it can be added to an already existing cluster.
A node that is removed from the topology moves back to the Passive state.
||Has no Leader and tries to get elected for leadership.
||Has a Leader and operates normally.
||Just elected for leadership, but will take office and become the leader only after the dummy
noop raft command was successfully applied in the cluster.
||Leader of the cluster. See more below.
Cluster Nodes States Flow
1. New server/node will start as Passive, meaning it is not part of any cluster yet.
2. When a node is added to a cluster, it immediately becomes the Leader if it is the only node in the cluster.
3. When a node is added to a cluster and a Leader already exists, it will become Promotable (on its way to either becoming a Member or a Watcher - depending on what was specified when created.)
4. Node will become a Member of the cluster if not specified otherwise.
5. Node will become a Watcher if specified when adding the node.
6. Member can be
Demoted to a Watcher.
7. Watcher can be
Promoted to a Member. It will first become Promotable and a Member thereafter.
8. Member (a regular Member or a Leader - but not a Watcher) can become a Candidate when a voting process for a new Leader takes place.
9. When voting is over and a new Leader is elected, one candidate becomes the Leader and the rest go back to being his Followers.
The Leader makes sure that decisions are consistent at the cluster level, as long as a majority of the nodes are functioning and can talk to the Leader.
For example, the decision to add a database to a node will be either accepted by the entire cluster (eventually) or fail to register altogether.
Raft Commands can't be accepted while there is no Leader or if the Leader is down.
Increase your RavenDB cluster by adding Watchers with the advantage of not suffering from large voting majorities and the latencies they can incur,
as watchers don't take part in majority calculations.
A Watcher can be assigned databases and tasks as a regular Member but is not included in the decisions making flow,
so cluster decisions can be made with a small majority of nodes while the actual size of the cluster can be much higher.
Any number of Watchers can be added to handle the workload.