TINYRAFT
TinyRaft is a from-scratch implementation of the Raft consensus protocol in pure Python, with a linearizable, replicated key/value store on top. Real TCP transport, zero dependencies, and integration tests that kill leaders mid-write.
Raft powers etcd, Consul, TiKV and CockroachDB, yet most engineers only ever meet it as a dependency. I wanted to understand what actually happens when a leader dies in the middle of a write — and prove it with tests, not just read about it in a paper.
Leader election with randomized timeouts, pre-vote (9.6), log replication with next_index backtracking and membership changes — all over real sockets. Then an integration harness that crashes leaders and restarts nodes mid-flight, against the real transport, not mocks.
Ships on PyPI with CI, hosted docs and a test suite that survives node kills. Pre-vote alone stops stale leaders from disrupting a live one — the parts of the paper people usually skip are exactly the parts that keep production calm.