Giter Club home page Giter Club logo

zanredisdb's Introduction

ZanRedisDB

Codacy Badge GoBuild Status GitHub release codecov Go Report Card Documentation Status

What is ZanRedisDB

ZanRedisDB is a distributed redis cluster with strong consistency.

  • Compatible with redis protocol: most redis command is supported in ZanRedisDB, so you can replace Redis with ZanRedisDB and get a more powerful cluster with unlimited data.
  • Namespace and set supported: You can use the namespace and set as prefix to isolate different data to make operation more easily.
  • Strong consistence and persistence: Use raft and rocksdb to make sure all the data have the consistence replication and persistent on stable storage.
  • Scalability: You can easily increase the cluster capacity just by adding more machines.
  • Multi-DC support: multi data centers deployment can be supported with rackaware feature.

Build

Install the compress library

yum install snappy-devel (for CentOS)
apt-get install libsnappy1 libsnappy-dev (for Debian/Ubuntu)
brew install snappy (for Mac)

Build the rocksdb with jemalloc

git clone https://github.com/absolute8511/rocksdb.git
cd rocksdb
git checkout v6.4.6-patched
PORTABLE=1 USE_SSE=1 USE_PCLMUL=1 WITH_JEMALLOC_FLAG=1 JEMALLOC=1 make static_lib

Install the dependency (for old go version only, if using go1.13+, it will be done in go modules):

CGO_CFLAGS="-I/path/to/rocksdb/include" CGO_LDFLAGS="-L/path/to/rocksdb -lrocksdb -lstdc++ -lm -lsnappy -lrt -ljemalloc" go get github.com/youzan/gorocksdb

CGO_CFLAGS="-I/path/to/rocksdb/include" CGO_LDFLAGS="-L/path/to/rocksdb -lrocksdb -lstdc++ -lm -lsnappy -ljemalloc" go get github.com/youzan/gorocksdb (for MacOS)

use the dep ensure to install other dependencies or use go modules for go1.13+

Build zankv and placedriver from the source (only support go version 1.10+, gcc 4.9+ or xcode-command-line-tools on Mac):

ROCKSDB=/path/to/rocksdb make

If you want package the binary release run the scripts

./pre-dist.sh
ROCKSDB=/path/to/rocksdb ./dist.sh

Deploy

  • Deploy the rsync daemon which is needed on all server node to transfer the snapshot data for raft
  • Deploy etcd cluster which is needed for the meta data for the namespaces
  • Deploy the placedriver which is used for data placement: placedriver -config=/path/to/config
  • Deploy the zankv for data storage server zankv -config=/path/to/config
  • Init a namespace using the create the namespace API in placedriver

OS-Level Tuning

  • Setting vm.swappiness=0
  • Setting vm.min_free_kbytes to at least 1GB (8GB on larger memory system)
  • Disable NUMA zone reclaim with vm.zone_reclaim_mode=0
  • Disable THP(transparent huge pages)
  • Avoid the tcp delay ack by echo 4 > /proc/sys/net/ipv4/tcp_delack_min (for old OS only)

API

placedriver has several HTTP APIs to manager the namespace

  • list the namespace: GET /namespaces
  • list the data nodes: GET /datanodes
  • list the placedriver nodes: GET /listpd
  • query the namespace meta info: GET /query/namespace_name
  • create the namespace (handle only by leader) : POST /cluster/namespace/create?namespace=test_p16&partition_num=16&replicator=3
  • delete the namespace (handle only by leader): POST /cluster/namespace/delete?namespace=test_p16&partition=**

storage server HTTP APIs for stats:

  • namespace stats : GET /stats
  • namespace raft internal stats : GET /raft/stats
  • optimize the data storage : POST /kv/optimize
  • get the raft leader of the namespace partition: GET /cluster/leader/namespace-partition

storage server also support the redis apis for read/write :

  • KV:
  • Hash Set:
  • List:
  • Sorted Set:
  • ZSet:

Client

Golang client SDK : client-sdk , a redis proxy can be deployed based on this golang sdk if you want use the redis client in other language.

Architechture

arch

Roadmap

  • Redis data structures
    • KV
    • Hash
    • List
    • Set
    • Sorted Set
    • GeoHash
    • Expires
    • HyperLogLog
    • JSON
  • Distributed system
    • Raft based replication
    • Partitions
    • Auto balance and migrate
    • Support namespace
    • High available
    • Distributed scan on table
    • Rackaware deployment used for across data center deployment
  • Searchable and Indexing
    • Secondary index support on Hash fields
    • Secondary index support for json kv
    • Full text search support
  • Operation
    • Backup and restore for cluster
    • More stats for read/write performance and errors.
  • Client
    • High available for redis commands (Retry on fail)
    • Extand redis commands to support index and search
    • Extand redis commands for advance scan
  • Others (maybe)
    • Support configure for Column storage friendly for OLAP
    • Pebble as the storage engine
    • Support other memory storage engine
    • Support export data to other systems

Thanks

Many thanks for these great projects which make this project possible: etcd, RocksDB, ledisdb, pika.

zanredisdb's People

Contributors

absolute8511 avatar bluefoxah avatar codacy-badger avatar wangjian-pg avatar wusphinx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zanredisdb's Issues

负载均衡的时候kv进程core掉

在测试系统负载均衡的时候,kv进程core掉,callstack如下:

#0 runtime.raise () at /usr/local/go/src/runtime/sys_linux_amd64.s:113
#1 0x000000000044e5d2 in runtime.raisebadsignal (sig=11, c=0x7f4e517f7ed8) at /usr/local/go/src/runtime/signal_unix.go:453
#2 0x000000000044ea33 in runtime.badsignal (sig=11, c=0x7f4e517f7ed8) at /usr/local/go/src/runtime/signal_unix.go:562
#3 0x000000000044e1eb in runtime.sigtrampgo (sig=11, info=0x7f4e517f80b0, ctx=0x7f4e517f7f80) at /usr/local/go/src/runtime/signal_unix.go:282
#4 0x0000000000469b83 in runtime.sigtramp () at /usr/local/go/src/runtime/sys_linux_amd64.s:265
#5
#6 0x00007f4e5bad90d0 in std::string::assign(std::string const&) () from /lib64/libstdc++.so.6
#7 0x00007f4e5bf95a64 in operator= (__str=..., this=0x7f4e517f8670) at /usr/include/c++/4.8.2/bits/basic_string.h:547
#8 operator= (this=) at ./db/dbformat.h:170
#9 rocksdb::CompactionPicker::GetRange (this=0x7f4da0a288c0, inputs=..., smallest=smallest@entry=0x7f4e517f8660, largest=largest@entry=0x7f4e517f8670) at db/compaction_picker.cc:152
#10 0x00007f4e5bf9c1c8 in PickFileToCompact (this=, this=, this=, this=, this=) at db/compaction_picker.cc:1357
#11 SetupInitialFiles (this=) at db/compaction_picker.cc:1104
#12 PickCompaction (this=0x7f4e517f8720) at db/compaction_picker.cc:1216
#13 rocksdb::LevelCompactionPicker::PickCompaction (this=, cf_name=..., mutable_cf_options=..., vstorage=, log_buffer=) at db/compaction_picker.cc:1400
#14 0x00007f4e5bf7235c in rocksdb::ColumnFamilyData::PickCompaction (this=this@entry=0x7f4da0a27ee0, mutable_options=..., log_buffer=log_buffer@entry=0x7f4e517f91f0) at db/column_family.cc:812
#15 0x00007f4e5bfcb6f4 in rocksdb::DBImpl::BackgroundCompaction (this=this@entry=0x7f4da0a3fd40, made_progress=made_progress@entry=0x7f4e517f8fce, job_context=job_context@entry=0x7f4e517f8ff0, log_buffer=log_buffer@entry=0x7f4e517f91f0,
prepicked_compaction=prepicked_compaction@entry=0x0) at db/db_impl_compaction_flush.cc:1526
#16 0x00007f4e5bfce1f4 in rocksdb::DBImpl::BackgroundCallCompaction (this=this@entry=0x7f4da0a3fd40, prepicked_compaction=prepicked_compaction@entry=0x0, bg_thread_pri=bg_thread_pri@entry=rocksdb::Env::LOW) at db/db_impl_compaction_flush.cc:1343
#17 0x00007f4e5bfce6bf in rocksdb::DBImpl::BGWorkCompaction (arg=) at db/db_impl_compaction_flush.cc:1162
#18 0x00007f4e5c1170b8 in rocksdb::ThreadPoolImpl::Impl::BGThread (this=this@entry=0x7f4e48007a60, thread_id=thread_id@entry=0) at util/threadpool_imp.cc:237
#19 0x00007f4e5c11729d in rocksdb::ThreadPoolImpl::Impl::BGThreadWrapper (arg=0x7f4e48009970) at util/threadpool_imp.cc:261
#20 0x00007f4e5bacf360 in ?? () from /lib64/libstdc++.so.6
#21 0x00007f4e5c4b7e25 in start_thread () from /lib64/libpthread.so.0
#22 0x00007f4e5ac15bad in clone () from /lib64/libc.so.6
(gdb) f 9
#9 rocksdb::CompactionPicker::GetRange (this=0x7f4da0a288c0, inputs=..., smallest=smallest@entry=0x7f4e517f8660, largest=largest@entry=0x7f4e517f8670) at db/compaction_picker.cc:152
152 db/compaction_picker.cc: No such file or directory.
(gdb) p inputs
$1 = (const rocksdb::CompactionInputFiles &) @0x7f4e517f8760: {level = 2, files = std::vector of length 0, capacity 1}
(gdb)

很显然是上面最后一个inputs的vector为空导致的,请fix下这个bug。

Support lots of expire data in a fixed period

Some data in kv will be expired in a fixed period, such as in every day or every month. And these data may be huge in the expire cycle. We need optimize this case by using some special strategy (use the time-cycle as the table prefix can be a choose.)
In this expire strategy: set/expire/ttl command should return not allowed, only allow the setex command and the timeout should not larger than the configured expire cycle.

Distributed secondary index query on hash

Support distributed secondary index query on hash based on the #7 .

Should return the results by the order of the secondary index across the multi partitions in the namespace.

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.