Skip to content

huiming23344/raft-kv

Repository files navigation

raft-kv

Go Report Card License Build

English | 中文

Introduction

A simple key-value store with raft consensus algorithm.

Features

RESP

"RESP is a binary protocol that uses control sequences encoded in standard ASCII. The A character, for example, is encoded with the binary byte of value 65. Similarly, the characters CR (\r), LF (\n) and SP ( ) have binary byte values of 13, 10 and 32, respectively. The \r\n (CRLF) is the protocol's terminator, which always separates its parts."

RESP data type Minimal protocol version Category First byte
Simple strings RESP2 Simple +
Simple Errors RESP2 Simple -
Integers RESP2 Simple :
Bulk strings RESP2 Aggregate $
Arrays RESP2 Aggregate *

BenchMark

test with redis-benchmark

====== SET ======
  10000 requests completed in 6.95 seconds
  50 parallel clients
  3 bytes payload
  keep alive: 1
  multi-thread: no
  
Summary:
  throughput summary: 1621.27 requests per second
  latency summary (msec):
          avg       min       p50       p95       p99       max
       30.675     5.808    29.455    45.631    53.087   254.079

Running

start the server

go run main.go

cd to the kvsctl directory and run the following commands to interact with the server.

go build -o kvsctl

# Get and Set
./kvsctl GET name
# you can also specify the address of the server
# if you want to change the default address of the server
# you can modify the `kvsctl` file
./kvsctl GET name -a 127.0.0.1:2317

# Raft Cluster 
./kvsctl member add 127.0.0.1:2317 127.0.0.1:2318
./kvsctl member remove 127.0.0.1:2317
./kvsctl member list

Supported commands

Reference