中文 | English
eRaft is a high-performance distributed key-value storage system implemented in Go. It features:
See INSTALL.md for detailed installation and build instructions for macOS and Linux.
Detailed information about the system design and implementation can be found in our project Wiki:
This project was built with the assistance of AI, representing a paradigm shift in software engineering efficiency:
graph LR
A[Traditional Coding] --> B[Horse Carriage Era]
B --> C[Manual Boilerplate]
B --> D[Painful Debugging]
E[AI-Assisted Coding] --> F[Steam Engine Era]
F --> G[Intelligent Generation]
F --> H[Automated Testing]
C -.-> I[Low Efficiency]
D -.-> I
G -.-> J[High Efficiency]
H -.-> J
For detailed installation instructions, see INSTALL.md.
To build all components, run:
make build
Binaries will be generated in the output/ directory.
Note: eRaft uses RocksDB as the storage engine. Please ensure RocksDB is installed on your system before building. See INSTALL.md for platform-specific instructions.
The configuration cluster manages shard assignments. Start 3 nodes:
# Terminal 1
./output/shardctrlerserver -id 0 -cluster "localhost:50051,localhost:50052,localhost:50053" -db "data/sc0"
# Terminal 2
./output/shardctrlerserver -id 1 -cluster "localhost:50051,localhost:50052,localhost:50053" -db "data/sc1"
# Terminal 3
./output/shardctrlerserver -id 2 -cluster "localhost:50051,localhost:50052,localhost:50053" -db "data/sc2"
A ShardKV group stores the actual data. We will start two groups (GID 100 and GID 101) to demonstrate sharding.
# Terminal 4, 5, 6
./output/shardkvserver -id 0 -gid 100 -cluster "localhost:6001,localhost:6002,localhost:6003" -ctrlers "localhost:50051,localhost:50052,localhost:50053" -db "data/skv100_0"
./output/shardkvserver -id 1 -gid 100 -cluster "localhost:6001,localhost:6002,localhost:6003" -ctrlers "localhost:50051,localhost:50052,localhost:50053" -db "data/skv100_1"
./output/shardkvserver -id 2 -gid 100 -cluster "localhost:6001,localhost:6002,localhost:6003" -ctrlers "localhost:50051,localhost:50052,localhost:50053" -db "data/skv100_2"
# Terminal 7, 8, 9
./output/shardkvserver -id 0 -gid 101 -cluster "localhost:7001,localhost:7002,localhost:7003" -ctrlers "localhost:50051,localhost:50052,localhost:50053" -db "data/skv101_0"
./output/shardkvserver -id 1 -gid 101 -cluster "localhost:7001,localhost:7002,localhost:7003" -ctrlers "localhost:50051,localhost:50052,localhost:50053" -db "data/skv101_1"
./output/shardkvserver -id 2 -gid 101 -cluster "localhost:7001,localhost:7002,localhost:7003" -ctrlers "localhost:50051,localhost:50052,localhost:50053" -db "data/skv101_2"
Use the shardctrlerclient to register both groups to the configuration cluster:
# Register Group 100
./output/shardctrlerclient join 100=localhost:6001,localhost:6002,localhost:6003
# Register Group 101
./output/shardctrlerclient join 101=localhost:7001,localhost:7002,localhost:7003
Now you can read and write data using the shardkvclient:
# Write data
./output/shardkvclient put mykey myvalue
# Read data
./output/shardkvclient get mykey
# Append data
./output/shardkvclient append mykey " extra"
# Run benchmark
./output/shardkvclient bench 1000
Check the status of all nodes in the cluster:
# ShardKV status
./output/shardkvclient status
# ShardCtrler status
./output/shardctrlerclient status
The Dashboard provides a web interface for real-time monitoring of cluster status, topology, and performance metrics.
# Build backend server
make builddashboard
# Build frontend (first time requires dependency installation)
cd dashboard/frontend
npm install # Pre-configured with Taobao mirror for users in China
npm run build
# Start the Dashboard server (run after completing Steps 1-3)
./output/dashboard-server \
-port=8080 \
-config-addrs="localhost:50051,localhost:50052,localhost:50053" \
-update-interval=5s
Then access in your browser: http://localhost:8080
The Dashboard provides the following features:
When you use the move command or when the configuration changes (due to join/leave), the system performs an automatic data migration:
shardctrler updates the shard-to-group mapping.shardkv group leader periodically polls the controller for configuration changes.Pulling and starts fetching data from the previous owner.