Giter Club home page Giter Club logo

caskdb's Introduction

Caskdb

Introduction

Caskdb is a distributed key-value store inspired by consistent hashing, beansdb and beanseye. I implemented it for learning purpose.

Features

  • automatic data partition
  • dynamic node adding
  • multiple replication
  • data recovery (when restarting after crashed)

How to Install

Install Go first, then

go clone URL(caskdb, bitcask_go)
mv caskdb bitcask_go GOPATH/src/
go get github.com/robfig/config
go install caskdb/master
go install caskdb/datanode

How to run

master

Prepare configure file(according to caskdb/master/conf/example.ini) and make sure static/ is in current path

> master

datanode

datanode -port=7901 -dbpath="test1" -debug
datanode -port=7902 -dbpath="test2" -debug

monitor

Open localhost:7908 in browser to monitor the state of datanodes

bench

cd caskdb/bench
go build
./bench -sz=1K -n=1000 -t=W 

Document

General Design

Caskdb is designed under the master-slave architecture. Master node is responsible to receiving all requests from clients and send them to data nodes according to its data partition algorithm. It also serves as a cluster monitor which provides a web interface. Data nodes mainly provide an efficient set,get and delete interfaces to outside.

Data Partition

  1. In Caskdb, the mapping relationship between keys and nodes are determined by consistent hashing algorithm.
  2. Every key/value pair is stored in two different nodes.

Node Adding

  1. Modify the configure file(add address of new node).
  2. Master node will notice the update of configure file, recalculate the hashing circle and send data migration tasks.
  3. Some data nodes will execute the migration tasks.
  4. After all tasks are done, the new node is successfully added.

Key-Value Storage Engine

In Caskdb, the kv engine is an implementation of Bitcask. The merging operation could be triggered by size of datafile, time window and percentage of useless data.

type Options struct {
	MaxFileSize  int32
	MergeWindow  [2]int // startTime-EndTime
	MergeTrigger float32
	Path         string
}

Configure && Monitor

[default]
server_port=7900  # default port
servers=localhost:7901,localhost:7902

[proxy]
port=7905  # proxy port for accessing

[monitor]
port=7908   # monitor port for web 
proxy=localhost:7905   # proxy list to monitor

The monitor part is actually stoled from the monitor implementation in beanseye.

caskdb's People

Contributors

wenzhengjiang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.