Coder Social home page Coder Social logo

focinfi / oncekv Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 1.0 3.05 MB

Easy scaling distributed Key/Value dababase

License: Mozilla Public License 2.0

Shell 0.35% Go 91.19% Makefile 0.29% HTML 0.22% Vue 4.95% JavaScript 2.99%
golang kv-database cache raft groupcache

oncekv's Introduction

oncekv

Go Report Card Build Status

A key/value database, each pair of key/value can be set only one time.

Why limit the set time?

Cause we design oncekv for the scenarios like once a key set, it will never be changed, for example, a versioned cache file database.

At the same time, limitation gives us chances to improve performance but still easily to scale.

Design

diagram

  1. Performance, using groupcache for read cache.
  2. Reliable, using raft for consensus and boltdb for underlying database.
  3. Easy horizontal scaling, simple HTTP API, inspired by hraftf.

Have a try

1.Change working directory into example

cd $GOPATH/src/github.com/Focinfi/oncekv/example

2.Start the admin server

go run ./admin/admin.go

This server provide API of known server list for the front end porject and starts the database master server.

3.Start the admin front end server

cd $GOPATH/src/github.com/Focinfi/oncekv/admin/oncekv
npm run dev

It shows only title, now, let's add a database node.

4.Start one database node

bash ./databases/node/node1.sh

Cause it's the only node of this raft cluster, so it becomes the Leader. And the admin page will show its stats.

Then add another node by bash ./databases/node/node2.sh

5.Start the cache cluster

Start the master:

go run ./cache/master/master.go;

Start the cache first node:

bash ./cache/node/node1.sh

Start the cache second node:

bash ./cache/node/node2.sh

Start the cache third node:

bash ./cache/node/node3.sh

6.Set/Get some key/vlaue pairs:

# set foo/bar into database leader
curl -XPOST http://127.0.0.1:11000/key -d '{"key":"foo","value":"bar"}'

# get for cache node-1
curl -XGET http://127.0.0.1:5551/key/foo

# get for cache node-2
curl -XGET http://127.0.0.1:5552/key/foo

# get for cache node-3
curl -XGET http://127.0.0.1:5553/key/foo

#... try more key/value

And then your admin page will look like this:

admin

Powered by vuejs and element

oncekv's People

Contributors

focinfi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

shepiluan

oncekv's Issues

Plan for v0.3.0

  1. replace http with net/rpc for master/node communication
  2. database shard

[BUG] accept: too many open files in system

When a cache or database node run locally about 20 minutes, it will raise a error: accept: too many open files in system.

Potential problem:

  1. websocket, close connection correctly
  2. mac max open file limitaion

Plan for v0.2.0

  1. Complete test, add test CI script. (failed to integerate into coveralls.io)
  2. Complete document
  3. Out of box play script. (write tutorial in README.md)

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.