TranNDC / godbee

An experimental & simple key-value service written in Go/C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GodBee

Build Status Project Level Coverage Status version version version

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:
# 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

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
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 unit tests

# Run test
make test

Benchmark

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

Documentation

Acknowledgements

Thanks AJ Pham for guiding us during the project.

About

An experimental & simple key-value service written in Go/C++


Languages

Language:C++ 69.4%Language:Go 28.8%Language:Makefile 0.8%Language:C 0.7%Language:Python 0.1%Language:Dockerfile 0.1%Language:Shell 0.1%