The TinyKV course builds a key-value storage system with the Raft consensus algorithm.

The TinyKV Course

The TinyKV course builds a key-value storage system with the Raft consensus algorithm. It is inspired by MIT 6.824 and TiKV Project.

After completing this course, you will have the knowledge to implement a horizontally scalable, highly available, key-value storage service with distributed transaction support. Also, you will have a better understanding of TiKV architecture and implementation.

Course Architecture

The whole project is a skeleton code for a key-value server and a scheduler server at the beginning - you need to finish the core logic step by step:

  • Standalone KV
    • Implement a standalone storage engine.
    • Implement raw key-value service handlers.
  • Raft KV
    • Implement the basic Raft algorithm.
    • Build a fault-tolerant KV server on top of Raft.
    • Add the support of Raft log garbage collection and snapshot.
  • Multi-raft KV
    • Implement membership change and leadership change to Raft algorithm.
    • Implement conf change and region split on Raft store.
    • Implement a basic scheduler.
  • Transaction
    • Implement the multi-version concurrency control layer.
    • Implement handlers of KvGet, KvPrewrite, and KvCommit requests.
    • Implement handlers of KvScan, KvCheckTxnStatus, KvBatchRollback, and KvResolveLock requests.

Code Structure

overview

Similar to the architecture of TiDB + TiKV + PD that separates the storage and computation, TinyKV only focuses on the storage layer of a distributed database system. If you are also interested in the SQL layer, please see TinySQL. Besides that, there is a component called TinyScheduler acting as a center control of the whole TinyKV cluster, which collects information from the heartbeats of TinyKV. After that, the TinyScheduler can generate scheduling tasks and distribute the tasks to the TinyKV instances. All of instances are communicated via RPC.

The whole project is organized into the following directories:

  • kv contains the implementation of the key-value store.
  • raft contains the implementation of the Raft consensus algorithm.
  • scheduler contains the implementation of the TinyScheduler, which is responsible for managing TinyKV nodes and generating timestamps.
  • proto contains the implementation of all communication between nodes and processes uses Protocol Buffers over gRPC. This package contains the protocol definitions used by TinyKV, and the generated Go code that you can use.
  • log contains utility to output log based on level.

Reading List

We provide a reading list for the knowledge of distributed storage system. Though not all of them are highly related with this course, they can help you construct the knowledge system in this field.

Also, you're encouraged to read the overview of TiKV's and PD's design to get a general impression on what you will build:

Build TinyKV from Source

Prerequisites

  • git: The source code of TinyKV is hosted on GitHub as a git repository. To work with git repository, please install git.
  • go: TinyKV is a Go project. To build TinyKV from source, please install go with version greater or equal to 1.13.

Clone

Clone the source code to your development machine.

git clone https://github.com/tidb-incubator/tinykv.git

Build

Build TiDB from the source code.

cd tinykv
make

It builds the binary of tinykv-server and tinyscheduler-server to bin dir.

Run TinyKV with TinySQL

  1. Get tinysql-server follow its document.
  2. Put the binary of tinyscheduler-server, tinykv-server and tinysql-server into a single dir.
  3. Under the binary dir, run the following commands:
mkdir -p data
./tinyscheduler-server
./tinykv-server -path=data
./tinysql-server --store=tikv --path="127.0.0.1:2379"

Now you can connect to the database with an official MySQL client:

mysql -u root -h 127.0.0.1 -P 4000

Contributing

Any feedback and contribution is greatly appreciated. Please see issues if you want to join in the development.

Owner
jaegerwang
email: [email protected] wechat: 13969003119
jaegerwang
Similar Resources

Distributed reliable key-value store for the most critical data of a distributed system

etcd Note: The main branch may be in an unstable or even broken state during development. For stable versions, see releases. etcd is a distributed rel

Dec 30, 2022

This is a comprehensive system that simulate multiple servers’ consensus behavior at local machine using multi-process deployment.

Raft simulator with Golang This project is a simulator for the Raft consensus protocol. It uses HTTP for inter-server communication, and a job schedul

Jan 30, 2022

gathering distributed key-value datastores to become a cluster

go-ds-cluster gathering distributed key-value datastores to become a cluster About The Project This project is going to implement go-datastore in a fo

Aug 19, 2022

⟁ Tendermint Core (BFT Consensus) in Go

⟁ Tendermint Core (BFT Consensus) in Go

Tendermint Byzantine-Fault Tolerant State Machines. Or Blockchain, for short. Branch Tests Coverage Linting master Tendermint Core is Byzantine Fault

Dec 26, 2022

A feature complete and high performance multi-group Raft library in Go.

A feature complete and high performance multi-group Raft library in Go.

Dragonboat - A Multi-Group Raft library in Go / 中文版 News 2021-01-20 Dragonboat v3.3 has been released, please check CHANGELOG for all changes. 2020-03

Dec 30, 2022

A linearizability distributed database by raft and wisckey.

AlfheimDB A linearizability distributed database by raft and wisckey, which supports redis client. Build This project build by mage, you will need ins

Jul 18, 2022

An implementation of a distributed KV store backed by Raft tolerant of node failures and network partitions 🚣

An implementation of a distributed KV store backed by Raft tolerant of node failures and network partitions 🚣

barge A simple implementation of a consistent, distributed Key:Value store which uses the Raft Concensus Algorithm. This project launches a cluster of

Nov 24, 2021

Easy to use Raft library to make your app distributed, highly available and fault-tolerant

Easy to use Raft library to make your app distributed, highly available and fault-tolerant

An easy to use customizable library to make your Go application Distributed, Highly available, Fault Tolerant etc... using Hashicorp's Raft library wh

Nov 16, 2022

BlobStore is a highly reliable,highly available and ultra-large scale distributed storage system

BlobStore Overview Documents Build BlobStore Deploy BlobStore Manage BlobStore License Overview BlobStore is a highly reliable,highly available and ul

Oct 10, 2022
Raft: a consensus algorithm for managing a replicated log

Raft Consensus Algorithm Raft is a consensus algorithm for managing a replicated

Dec 20, 2021
This is my implementation of Raft consensus algorithm that I did for own learning.

This is my implementation of Raft consensus algorithm that I did for own learning. Please follow the link to learn more about raft consensus algorithm https://raft.github.io. And Soon, I will be developing same algorithm in Java as well

Jan 12, 2022
Feb 3, 2022
Golang implementation of the Raft consensus protocol

raft raft is a Go library that manages a replicated log and can be used with an FSM to manage replicated state machines. It is a library for providing

Jan 9, 2023
Raft library Raft is a protocol with which a cluster of nodes can maintain a replicated state machine.

Raft library Raft is a protocol with which a cluster of nodes can maintain a replicated state machine. The state machine is kept in sync through the u

Oct 15, 2021
A distributed key-value storage system developed by Alibaba Group

Product Overview Tair is fast-access memory (MDB)/persistent (LDB) storage service. Using a high-performance and high-availability distributed cluster

Dec 31, 2022
A distributed MySQL binlog storage system built on Raft
A distributed MySQL binlog storage system built on Raft

What is kingbus? 中文 Kingbus is a distributed MySQL binlog store based on raft. Kingbus can act as a slave to the real master and as a master to the sl

Dec 31, 2022
Elastic Key-Value Storage With Strong Consistency and Reliability
Elastic Key-Value Storage With Strong Consistency and Reliability

What is Elasticell? Elasticell is a distributed NoSQL database with strong consistency and reliability. Compatible with Redis protocol Use Elasticell

Dec 28, 2022
Distributed disk storage database based on Raft and Redis protocol.
Distributed disk storage database based on Raft and Redis protocol.

IceFireDB Distributed disk storage system based on Raft and RESP protocol. High performance Distributed consistency Reliable LSM disk storage Cold and

Dec 31, 2022