godbee
godbee copied to clipboard
An experimental & simple key-value service written in Go/C++
GodBee

-
GodBee
- Overview
- Architecture
- Requirements
- Methods supported
- Build
- Run
-
Test
- Test CLI
- Run unit tests
- Benchmark
- Documentation
- Acknowledgements
Overview
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.
Architecture

Requirements
- C++17
- Golang 1.13.1
- Locust
- Python 3.7.3
- Docker Engine - Community 19.03.3
Methods supported
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) {}
}
Build
# Clone project
git clone https://github.com/zalopay-oss/godbee.git
Run
- Make CGO understands C++17
# Modify Go enviroment variable
export CGO_CXXFLAGS="-g -rdynamic -std=c++17 -o -pthread
- Run server:
# Run server
./server.sh
- Or run Docker server:
# Build docker image named "godbee-server"
docker build -t godbee-server .
# Run image
docker run -it --net="host" godbee-server
Test
Test CLI
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
./cli.sh
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 unit tests
# Run test
./test.sh
Benchmark
You can view benchmark results at here.
Benchmark system:
- ThinkPad X280
- CPU: Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
- 16GiB SODIMM DDR4 2400 MHz
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 |
Documentation
- Slide: B+ Tree, GodBee
- Blog:
Acknowledgements
Thanks AJ Pham for guiding us during the project.