cRaft
2023.10 – 12Raft distributed consensus service framework using C++ stackful coroutines
- Core implementation: Studied the original Raft paper and implemented leader election, heartbeats / log replication, snapshot compaction and transfer with C++, libgo and gRPC. Used co_timer for randomized timeouts and resets, and co_chan with voteRPC for inter-node elections.
- Replication and snapshots: Replaced single-entry heartbeat catch-up for lagging followers with indexed-range log transfer to reduce network I/O. Improved large-log recovery and used gRPC streams to synchronize file metadata and transfer large snapshots.
- Stability and performance: Kept clusters stable under concurrent log replication and leader failure / recovery tests across VMs and physical hosts. Optimized log persistence and committed-entry state-machine updates, achieving tens of thousands of cluster commits per second in self-run tests, a 3–4× improvement over the initial version.
- Architecture: Used dependency injection and the template method pattern to encapsulate snapshot storage, log persistence and loading. Exposed only custom serialization / deserialization interfaces to reduce coupling between consensus and application layers.