Event Driven State Machine - RAFT Demo

Hi,
I was recently looking at the RAFT consensus algorithm and I thought it would make an interesting exercise to implement the basic election algorithm as a BPMN process. Hence please find my initial model as per below;

The process model is executable and can be deployed directly into the engine. I have included a driver process to start a cluster of nodes. Each node is simulated by a distinct process instance. On start up, one of the process instances will be elected as leader.

To simulate node failure, you can pause a process instance. If you pause the leader, you will force an election and a new leader will emerge. If you resume the old leader, it will detect that it has been usurped and transition back to follower. If you pause enough followers such that a majority cannot be obtained and force an election, then the cluster will fail to converge on a new leader.

Of interest here may be the use of event based gateways coupled with message events and conditional events as a working example.

If there’s interest, perhaps I will expand this beyond the basic election process…

enjoy,

regards

Rob

RAFTv4.bpmn (67 KB)

7 Likes

Great Job! BTW: here is Zeebe’s implementation: https://github.com/zeebe-io/zeebe/tree/develop/raft/src/main/java/io/zeebe/raft/state

1 Like