https://github.com/zalopay-oss/godbee
An experimental & simple key-value service written in Go/C++
https://github.com/zalopay-oss/godbee
Last synced: about 1 month ago
JSON representation
An experimental & simple key-value service written in Go/C++
- Host: GitHub
- URL: https://github.com/zalopay-oss/godbee
- Owner: zalopay-oss
- Created: 2019-12-20T04:28:43.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-29T18:32:25.000Z (over 5 years ago)
- Last Synced: 2024-06-19T02:00:26.904Z (over 1 year ago)
- Language: C++
- Homepage:
- Size: 33.8 MB
- Stars: 28
- Watchers: 6
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# **GodBee**
  
[](https://github.com/zalopay-oss/key-value-store-service) [](https://github.com/zalopay-oss/key-value-store-service/graphs/contributors) [](https://github.com/zalopay-oss/key-value-store-service/issues)
![]()
- [**GodBee**](#godbee)
- [**Overview**](#overview)
- [**Architecture**](#architecture)
- [**Requirements**](#requirements)
- [**Methods supported**](#methods-supported)
- [**Build**](#build)
- [**Run**](#run)
- [**Test**](#test)
- [Test CLI](#test-cli)
- [Run unit tests](#run-unit-tests)
- [**Benchmark**](#benchmark)
- [**Documentation**](#documentation)
- [**Acknowledgements**](#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**
```java
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**
```sh
# Clone project
git clone https://github.com/zalopay-oss/godbee.git
```## **Run**
- Make CGO understands C++17
```sh
# Modify Go enviroment variable
export CGO_CXXFLAGS="-g -rdynamic -std=c++17 -o -pthread
```- Run server:
```sh
# Run server
./server.sh
```- Or run Docker server:
```sh
# 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](#run), you can use GodBee-CLI to send commands to GodBee, and read the replies sent by the server, directly from the terminal.
**Run CLI**:
```sh
# Build and run client
./cli.sh
```**Command line usage**:
- **Connect** to B/B+ Storage:
```sh
# CONNECT {B | BPLUS}
GodBee > CONNECT B
OK
```- **Disconnect** to the storage:
```sh
# CLOSE
GodBee > CLOSE
OK
```- **Insert** new Key-Value:
```sh
# SET key value
GodBee > SET a a
OK
```- **Get** value from key:
```sh
# GET key
GodBee > GET a
"a"
```- **Remove** key:
```sh
# {REMOVE|DEL} key
GodBee > DEL a
OK
```- Check whether key **exists** in storage or not.
```sh
# EXIST key
GodBee > EXIST a
FALSE
```- Exit program
```sh
GodBee > exit
Bye bye!!! Beeeeee~
```### Run unit tests
```sh
# Run test
./test.sh
```## **Benchmark**
You can view benchmark results at [here](docs/benchmark.md).
Benchmark system:
- ThinkPad X280
- CPU: Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
- 16GiB SODIMM DDR4 2400 MHzP99 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](docs/B+tree.pdf), [GodBee](docs/GodBee.pdf)
- Blog:
- [Implement Key-Value Storage using Golang and C++ pt.1](https://medium.com/zalopay-engineering/cài-đặt-key-value-store-service-bằng-go-và-c-phần-1-storage-565b1a3f7e1b)
- [Implement Key-Value Storage using Golang and C++ pt.2](https://medium.com/zalopay-engineering/cài-đặt-key-value-store-service-bằng-go-và-c-phần-2-service-937737ae515e)## **Acknowledgements**
Thanks [AJ Pham](https://github.com/phamtai97) for guiding us during the project.