Skip to content
All projects
SystemsCompleted

RaftKV

A fault-tolerant, distributed key-value store built from scratch in Go on top of the Raft consensus algorithm.

Rows of server racks with glowing status lights in a modern data center

Key results

  • Sustains 50,000 reads per second on a three-node cluster
  • Elects a new leader in under 300 ms after a crash
  • Verified with a fault-injection suite covering thousands of failure scenarios

Why I built it

After our distributed systems course I wanted to truly understand how databases like etcd stay consistent when machines fail. The best way to learn it was to build one.

How it works

Each node runs a Raft state machine that handles leader election, log replication and snapshots. Clients talk to the cluster over gRPC, and a write is acknowledged only after a majority of nodes have stored it.

  • Leader election with randomised timeouts and pre-vote to avoid disruptive elections
  • Log compaction through periodic snapshots
  • Linearisable reads using read-index requests

What I learned

Testing was the hardest part. I wrote a fault-injection harness that kills nodes, partitions the network and reorders messages at random, then checks the recorded history for consistency violations.