This project is a distributed key-value (KV) store written in C++. It evolves over five phases—each improving on scalability, durability, and fault tolerance. By the final phase, it supports leader election using the Bully algorithm, enabling robust coordination across a distributed system.
Development is structured into Git branches, one per phase, allowing easy progression and experimentation.
Branch: main
Implements a simple thread-safe, in-memory key-value store.
Key Features:
GET
,SET
,DEL
operations- Command-line or API interface
Branch: append_log
Introduces write-ahead logging to persist changes and enable recovery.
Key Features:
- Log every write operation
Branch: networking
Adds TCP networking to serve remote clients.
Key Features:
- TCP-based server-client model
- Message parsing and framing
- Concurrent client handling
Branch: replication
Enables data replication across follower nodes.
Key Features:
- Synchronous/asynchronous replication
- Modular server-client refactor
- Redundancy for fault tolerance
Branch: leader-election
Implements dynamic leader election based on node priorities.
Key Features:
- Bully election protocol
- Automatic failover and re-election
- Leader coordination for write operations
Ensure CMake is installed and a C++17-compatible compiler is available.
mkdir build
cd build
cmake ..
cmake --build .
./kvstore
Start server:
./kvstore_server
Start server:
./kvstore_server <PORT> <PEER1>:<PORT>,<PEER2>:<PORT2>,<PEERN>:<PORTN>
Start client:
./kvstore_client <IP_ADDRESS> <PORT>
Phase | Branch Name | Description |
---|---|---|
1 | main |
In-memory key-value store |
2 | append_log |
Adds persistent write-ahead logging |
3 | networking |
Enables client-server networking |
4 | replication |
Adds replication and modularizes codebase |
5 | leader-election |
Introduces leader election (Bully algorithm) |
- C++17
- CMake
- POSIX Sockets
- Multithreading (
std::thread
,std::mutex
) - File I/O Logging
- Consensus protocol integration (e.g., Raft)
- HTTP/REST interface
- Dynamic service discovery
- Cluster rebalancing
Contributions are welcome! Each phase is independently accessible via its respective branch. Ensure code is tested and adheres to existing structure.
This project is licensed under the MIT License.