GodBee is a Key-Value Store Service project. In this project, we choose B-Tree and B+Tree data structures to organize and manipulate data. Key-Value Storage is written in C++ and Service layer is written in Golang programming language. We use gRPC services to handle requests from client and use CGO to access data from C++ storage.
- C++17
- Golang 1.13.1
- Locust
- Python 3.7.3
- Docker Engine - Community 19.03.3
syntax = "proto3";
package service;
service KeyValueStoreService {
rpc Connect (ConnectionRequest) returns (MessageResponse){}
rpc Disconnect (DisconnectRequest) returns (MessageResponse) {}
rpc Get (GetRequest) returns (GetResponse) {}
rpc Set (SetRequest) returns (MessageResponse) {}
rpc Remove (RemoveRequest) returns (RemoveResponse) {}
rpc Exist (ExistRequest) returns (ExistResponse) {}
}
# Clone project
git clone https://github.com/zalopay-oss/godbee.git
- Make CGO understands C++17
# Modify Go enviroment variable
export CGO_CXXFLAGS="-g -rdynamic -std=c++17 -o -pthread
- Run server:
# Build server
make build-server
# Run server
./server
- Or run Docker server:
# Build docker image named "godbee-server"
docker build -t godbee-server .
# Run image
docker run -it --net="host" godbee-server
After run server, you can use GodBee-CLI to send commands to GodBee, and read the replies sent by the server, directly from the terminal.
Run CLI:
# Build and run client
make cli
Command line usage:
- Connect to B/B+ Storage:
# CONNECT {B | BPLUS}
GodBee > CONNECT B
OK
- Disconnect to the storage:
# CLOSE
GodBee > CLOSE
OK
- Insert new Key-Value:
# SET key value
GodBee > SET a a
OK
- Get value from key:
# GET key
GodBee > GET a
"a"
- Remove key:
# {REMOVE|DEL} key
GodBee > DEL a
OK
- Check whether key exists in storage or not.
# EXIST key
GodBee > EXIST a
FALSE
- Exit program
GodBee > exit
Bye bye!!! Beeeeee~
# Run test
make test
You can view benchmark results at here.
P99 overview (miliseconds)
Percentile | Storage | Exist | Get | Remove | Set |
---|---|---|---|---|---|
50% | B-Store | 20 | 19 | 88 | 110 |
B+Store | 21 | 20 | 87 | 110 | |
99% | B-Store | 36 | 35 | 270 | 270 |
B+Store | 39 | 37 | 250 | 270 | |
100% | B-Store | 71 | 59 | 880 | 1000 |
B+Store | 77 | 75 | 810 | 1000 |
Thanks AJ Pham for guiding us during the project.