Git Product home page Git Product logo

youzan / zanredisdb Goto Github PK

View Code? Open in Web Editor NEW

This project forked from absolute8511/zanredisdb

387.0 31.0 60.0 8.02 MB

Yet another distributed fault-tolerant key-value database Compatible with Redis written in Golang.

License: MIT License

Makefile 0.13% Go 87.23% Shell 0.51% HTML 3.40% Python 0.06% JavaScript 3.11% Dockerfile 0.06% C++ 1.29% C 0.06% SCSS 4.15%
raft redis kvstore sharding distributed-database rocksdb json hyperloglog geohash key-value

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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zanredisdb's Issues

k8s operator

Support using the k8s operator to deploy a full cluster with the PersistentVolume

按照文档编译,RocksDB 编译失败

PORTABLE=1 USE_SSE=1 USE_PCLMUL=1 WITH_JEMALLOC_FLAG=1 JEMALLOC=1 make static_lib

$DEBUG_LEVEL is 0
GEN util/build_version.cc
$DEBUG_LEVEL is 0
GEN util/build_version.cc
CC cache/clock_cache.o
CC cache/lru_cache.o
CC cache/sharded_cache.o
CC db/builder.o
In file included from db/builder.cc:16:
In file included from ./db/compaction/compaction_iterator.h:13:
In file included from ./db/compaction/compaction.h:11:
In file included from ./db/version_set.h:31:
In file included from ./db/column_family.h:18:
In file included from ./db/table_cache.h:25:
In file included from ./table/table_reader.h:14:
./table/get_context.h:91:3: error: explicitly defaulted default constructor is implicitly deleted [-Werror,-Wdefaulted-function-deleted]
GetContext() = default;
^
./table/get_context.h:168:18: note: default constructor of 'GetContext' is implicitly deleted because field 'tracing_get_id_' of const-qualified
type 'const uint64_t' (aka 'const unsigned long long') would not be initialized
const uint64_t tracing_get_id_;
^
In file included from db/builder.cc:19:
./db/internal_stats.h:112:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
WAL_FILE_BYTES,
^
./include/rocksdb/statistics.h:196:3: note: previous declaration is here
WAL_FILE_BYTES, // Number of bytes written to WAL
^
In file included from db/builder.cc:19:
./db/internal_stats.h:113:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
WAL_FILE_SYNCED,
^
./include/rocksdb/statistics.h:195:3: note: previous declaration is here
WAL_FILE_SYNCED, // Number of times WAL sync is done
^
In file included from db/builder.cc:19:
./db/internal_stats.h:114:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
BYTES_WRITTEN,
^
./include/rocksdb/statistics.h:131:3: note: previous declaration is here
BYTES_WRITTEN,
^
In file included from db/builder.cc:19:
./db/internal_stats.h:115:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
NUMBER_KEYS_WRITTEN,
^
./include/rocksdb/statistics.h:124:3: note: previous declaration is here
NUMBER_KEYS_WRITTEN,
^
In file included from db/builder.cc:19:
./db/internal_stats.h:116:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
WRITE_DONE_BY_OTHER,
^
./include/rocksdb/statistics.h:201:3: note: previous declaration is here
WRITE_DONE_BY_OTHER, // Equivalent to writes done for others
^
In file included from db/builder.cc:19:
./db/internal_stats.h:117:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
WRITE_DONE_BY_SELF,
^
./include/rocksdb/statistics.h:200:3: note: previous declaration is here
WRITE_DONE_BY_SELF,
^
In file included from db/builder.cc:19:
./db/internal_stats.h:118:5: error: declaration shadows a variable in namespace 'rocksdb' [-Werror,-Wshadow]
WRITE_WITH_WAL,
^
./include/rocksdb/statistics.h:203:3: note: previous declaration is here
WRITE_WITH_WAL, // Number of Write calls that request WAL
^
8 errors generated.
make: *** [db/builder.o] Error 1

Do you have a wechat or slack to share useful application of ZanRedisDB ?

I'm apply redis-cluster in FeatureStore and model inference. Now I'm looking forward some disk-based KV store and I found ZanKV. Is there any good example of ZanKV applied to real scene? I recommend to create channel on slack or wechat group to share good ideas on this project? what do you think?

anyone working on redisearch add on?

any work started in this area?
Searchable and Indexing

Secondary index support on Hash fields
Secondary index support for json kv
Full text search support

Jepsen test

Support jepsen test to dig possible bugs for the distributed system.

使用rocksdb模拟实现redis zset的时间复杂度是否一样呢?

hi,感谢开源!我在文档找了下关于数据结构映射的文档,没有太详细的说明,曾经关注在rocksdb模拟redis跳表的实现,特别是rev 相关的命令,如: zrevrange、zrevrank、zrevrangebyscore。这些接口在既有的开源项目中实现的非常不理想,毕竟,leveldb的反向迭代器也是比正向慢多了,虽然官网只是提到一句:
image
我在另个实现中测试了其普通zrange的实现,大概1亿条数据,后来看到其实现是靠正向遍历:
image
这是完全不能用于生产环境的实现!
所以,zanRedisDB能否说明下一些操作的时间复杂度以及实现呢?

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.