A Python demo of a fault-tolerant distributed messaging backend inspired by distributed systems coursework on membership, Paxos, and DHTs.
- 3-node cluster with heartbeat-based membership
- deterministic leader election (lowest alive node id)
- leader-based ordered replication with quorum commit
- persistent committed log (
JSONL) - sharded conversation history ownership by hash
- simple CLI client for sending messages and reading logs
Open three terminals:
python -m app.main node --config configs/cluster.local.json --node-id 1
python -m app.main node --config configs/cluster.local.json --node-id 2
python -m app.main node --config configs/cluster.local.json --node-id 3python -m app.main send --config configs/cluster.local.json --node-id 2 --conversation general --sender alice --text "hello"
python -m app.main send --config configs/cluster.local.json --node-id 3 --conversation general --sender bob --text "hi"python -m app.main show-log --config configs/cluster.local.json --node-id 1
python -m app.main show-log --config configs/cluster.local.json --node-id 2
python -m app.main show-log --config configs/cluster.local.json --node-id 3Kill the leader process (node 1 by default), wait ~3 seconds, then send another message through node 2 or 3.
python -m app.main send --config configs/cluster.local.json --node-id 2 --conversation general --sender alice --text "still works"docker compose up --buildThis demo combines:
- membership + failure detection inspired by the membership service project
- ordered replicated commit inspired by Paxos / replicated-log ideas
- hash-based sharding inspired by the DHT project
This is an interview demo MVP, not a production-ready consensus implementation. It intentionally favors clarity and explainability over full protocol complexity.