A highly available distributed key value store.
There are 3 processes:
- leader - waits for the sync signal from the followers and sends back sync responses.
- follower - listens to port 10000 for incoming client requests and periodically syncs up with the leader.
- client - a test client sending request to a follower. Start the test client with default port, 10000.
To run in docker, skip to running with docker.
-
Install the protobuf compiler.
-
Install the Go protobuf plugin
-
Make sure your path includes
$GOPATH/bin
($HOME/go/bin
by default). -
The default configration is in
protos/config/local-config.pb.txt
; you can use your own config file to set a different port for example.
-
Run
make
to build the project. -
Binaries are in bin/.
Enter a foler, then run the test.
$ cd follower
$ go test
- Generate proto files Run script:
./proto-gen.sh
Or generate them seprately:
protoc -I protos protos/follower/follower.proto --go_out=plugins=grpc:protos/follower
protoc -I protos protos/leader/leader.proto --go_out=plugins=grpc:protos/leader
protoc -I protos protos/config/config.proto --go_out=plugins=grpc:protos/config
- You can start each process with
go run
:
go run distributed-key-value-store/leader
go run distributed-key-value-store/follower --follower_id=0
go run distributed-key-value-store/client --follower_id=0
You can specify the broadcast type by using flag --cast
, the supporting types are immediate
, periodic
and simple
.
-
Run
make docker
to build the three docker images:dkvs-leader
,dkvs-follower
, anddkvs-client
. -
Run them with docker, for example:
docker run --rm --network host dkvs-leader
- Run
test/run_test.sh
in the project dirctory