Hey all,
Over the past year, I have been working on an implementation of the Raft consensus algorithm in Haskell, which allows for distributed consensus. In particular, using Raft, one can create a distributed, fault-tolerant state machine. The library has been released on Hackage under the name raft-consensus. Bring your own networking and persistence layer!
Raft is tricky to get right. To ensure that the library works correctly, and respects the properties of the algorithm in practice, even under faults such as crashes and network partitions, I leveraged a technique called deterministic simulation testing (DST), using io-sim as the foundation. io-sim is pure awesomeness that should be used more.
While building out examples, I noticed other ecosystem holes that resulted in more packages. Testing the linearizability of client requests required building a simple linearizability checker: linearizable. Another piece of technology that came from this project is a generic and performant implementation of write-ahead logs via a new wal package.
Finally, in order to make it as easy as possible to build a replicated state machine in practice, I built two adapter packages:
- Networking of Raft clusters via Cloud Haskell:
raft-consensus-distributed-process - Persistence of Raft state via write-ahead logs:
raft-consensus-wal
I feel relatively confident in releasing this stuff now because, over the past week, I’ve been working on a demo: distributed software transactional memory. This program looks just like stm, but running over multiple computers.
Right now it’s just a demo, but it shows how freaking cool distributed state machines can be.
My goal, since I started helping with maintenance of Cloud Haskell, has been for Haskell to become a solid choice for distributed systems. We’re now one step closer to that reality.
If you’re interested in this stuff, I would love to get your input on this and collaborate. Development for all of this is happening here: GitHub - LaurentRDC/distributed-consensus: Haskell implementation of distributed consensus protocols with built-in support for deterministic simulation testing · GitHub