Helix Tutorial: State Machine Configuration
In this chapter, we'll learn about the state models provided by Helix, and how to create your own custom state model.
Helix comes with 3 default state models that are commonly used. It is possible to have multiple state models in a cluster. Every resource that is added should be configured to use a single state model that will govern its ideal state.
- Has 3 states: OFFLINE, SLAVE, MASTER
- Maximum # of masters: 1
- Slaves are based on the replication factor. The replication factor can be specified while adding the resource
Has 2 states: OFFLINE and ONLINE. This simple state model is a good starting point for most applications.
1 Leader and multiple stand-bys. The idea is that exactly one leader accomplishes a designated task, the stand-bys are ready to take over if the leader fails.
In addition to the state machine configuration, one can specify the constraints of states and transitions.
For example, one can say:
to indicate that the maximum number of replicas in MASTER state at any time is 1
to indicate that the maximum number of OFFLINE-SLAVE transitions that can happen concurrently in the system is 5 in this example.
Helix uses a greedy approach to satisfy the state constraints. For example, if the state machine configuration says it needs 1 MASTER and 2 SLAVES, but only 1 node is active, Helix must promote it to MASTER. This behavior is achieved by providing the state priority list as MASTER,SLAVE.
State Transition Priority
Helix tries to fire as many transitions as possible in parallel to reach the stable state without violating constraints. By default, Helix simply sorts the transitions alphabetically and fires as many as it can without violating the constraints. You can control this by overriding the priority order.