Rafty
is yet another golang library that manage to replicate log state machine.
Details about Raft protocol
can be found here
Reading this documentation is recommanded before going any further.
Check out these websites will also be useful:
There are many libraries out there implementing the search of an understandable consensus algorithm
.
Unfortunately, I mostly found them difficult to understand as there is not so much clear documentation about how to use them.
As examples, we have production ready repositories like:
So let's try to redo the wheel with more explanations.
Here is a list of the supported features of rafty
:
- PreVote election
- Leader election
- Leader lease
- Leadership transfer
- [] Logs
- Log replication
- Submit write commands
- Submit read commands
- Forward read/write commands to leader
- Log compaction
- Log storage
- etcd bbolt for long term storage
- log cache backed by etcd bbolt long term storage
- in memory storage (for development)
- Membership changes
- Add member
- promote member
- demote member
- remove member (with shutdown if proper flag set)
- forceRemove member
- leaveOnTerminate
- Single server cluster
- Bootstrap cluster
- Snapshot
- Take snapshot (with FSM interface)
- Restore snapshot (with FSM interface)
- InstallSnapshot RPC call
- Prometheus metrics
See real world app as implentation example.
- https://github.com/logcabin/logcabin
- https://github.com/funktor/distributed-hash-table/tree/raft
- https://www.cncf.io/blog/2019/11/04/building-a-large-scale-distributed-storage-system-based-on-raft/
- https://www.sofastack.tech/en/projects/sofa-jraft/consistency-raft-jraft/
- https://github.com/baidu/braft/blob/master/docs/cn/raft_protocol.md
- https://cwiki.apache.org/confluence/display/KAFKA/KIP-595%3A+A+Raft+Protocol+for+the+Metadata+Quorum
- https://towardsdatascience.com/raft-algorithm-explained-2-30db4790cdef
- https://www.alibabacloud.com/blog/raft-engineering-practices-and-the-cluster-membership-change_597742
- https://github.com/lni/dragonboat
- https://github.com/lni/dragonboat-example
- https://github.com/PlatformLab/epaxos/tree/master
- https://www.cs.princeton.edu/courses/archive/fall18/cos418/docs/p7-raft.pdf
- https://github.com/dgurkaynak/stalk-demo-raft-consensus/?tab=readme-ov-file
- https://github.com/ongardie/raft.tla