A powerful distributed systems project simulating cloud-native consensus models using a miniature version of the RAFT protocol. Multiple backend replicas maintain an identical event log of drawing strokes without relying on a central database, ensuring zero downtime even when containers crash.
- Leader Election: All nodes start as Followers. If they haven't heard from a Leader before a randomized timer expires, they become a Candidate and request votes. The first to achieve a majority becomes the Leader.
- Log Replication: The Leader is the only node trusted to accept client data. It appends the data (drawing strokes) to an immutable log and blasts it to Followers. Once a majority acknowledge, the state is committed.
- Fault Tolerance: If a node fails, it restarts and attempts to re-sync. If the Leader fails, followers notice the lack of heartbeats and securely elect a new one without disrupting data persistence.
graph TD
UI[HTML Canvas UI] -->|WebSocket| G(Gateway Proxy)
G -->|POST /submit-stroke| L[Leader Node: 3001]
L -.->|RPC /append-entries| F1[Follower Node: 3002]
L -.->|RPC /append-entries| F2[Follower Node: 3003]
L -.->|RPC /append-entries| F3[Follower Node: 3004]
- Ensure Docker Desktop is running.
- At the root of the project, run:
docker-compose up --buildThis boots the Gateway (Port 3000) and your Replica Nodes (3001+).
- In a separate terminal, navigate into the
frontendfolder:
cd frontend
npm install
npm run serve- Open
http://localhost:8080in multiple browser tabs to simulate clients.
- All system instances run over
httpinside local Docker bridges. Network latencies are artificially mimicked. - Logs are held in memory on the replicas and are not persisted entirely to physical disk arrays between total cluster teardowns (
docker-compose down).
- Leader election
- WebSocket Gateway
- Basic log replication
- Drawing canvas integration
- Graceful reload
- Blue-green replica replacement
- Failover correctness
- Multi-client real-time sync
- Demo under chaotic conditions
Bonus Options:
- Network partitions (simulate split brain)
- Add 4th replica
- Add vector-based undo/redo using log compensation
- Implement a dashboard showing leader, term, log sizes
- Deploy to a real cloud VM (e.g., Amazon Web Services (AWS) EC2 or Google Cloud)