Giter Site home page Giter Site logo

szstonelee / redrock_old Goto Github PK

View Code? Open in Web Editor NEW
13.0 2.0 4.0 6.92 MB

Redis can use storage like HDD or SSD

License: BSD 3-Clause "New" or "Revised" License

C 85.38% C++ 0.33% Makefile 0.26% Shell 0.37% Tcl 12.55% Ruby 0.30% Smarty 0.02% Python 0.32% Java 0.47% Dockerfile 0.01%
redis rocksdb cache nosql ssd hdd storage

redrock_old's Introduction

中文帮助请点这里, click here for Chinese documents

RedRock_old (depreciated) Homepage

Introduction

RedRock is a combination of Redis and RocksDB.

Why

Redis is a wonderful NoSQL based on memory. But memory costs more than disk. We hope something,

  • Same fast and strong as Redis
  • Extend to disk (HDD or SSD)

As SSD is becoming cheaper and has good performance, it is why I, enigneer Stone, code RedRock.

I wish one stone to hit two birds.

NOTE: I only code the project for a couple of months and only use my off-busy-work time. It is not as mature as a project for ten years. Wish you use it more and leave feedbacks at Github. Thank you.

Key Design

RedRock stores all Redis keys in memory, and can store ONLY the keys.

If memory is not enough for holding all key/values, RedRock will save some values to disk and later retrieve the values from the disk if clients need them. Usually the size of value is bigger than key. If value size is 100 times than key, the dataset can be 100 times than the limit of memory. If more key/values are coming over the 100 times limit, RedRock will evict some keys totally by LRU/LFU.

For the performance, if most requests visit key/value in memory, RedRock is same as Redis, usually hundreds kilo qps with 99% latnecy of sub 1ms for one machine. If more visits are coming to the keys which values are in disk, the performance can degrade rapidlly. You can check the benchmark for different patterns.

So the best user case for RedRock is hot key/value fitting in memory with a huge warm/cold values in disk. This way, we achieve the performance of latency similar to Redis and much-over-meomroy-size-limit dataset like traditional DB.

RedRock uses the Redis persistent ways like AOF/RDB. Because the dataset would be much bigger than memory, you need some advice for the persistency.

RedRock Features

  • Pure Redis. When no enable disk, RedRock is running almost the same codes as Redis
  • Use Redis Protocol, so no need to adjust one line of your client codes or config files
  • Keep all keys in memory but only hot key's value in memory with most other values in disk
  • Your dataset volume can be one hundred times of your memory
  • Support all Redis commands except module's commands
  • Support expire and eviction, you can use it as Cache
  • Support all Redis data structures, including String,List,Set,Hash,SortedSet,Stream,HyperLogLog,Geo
  • Support persistence, including RDB and AOF, in fork() child process or main thread
  • Can config maximum memory
  • Policy for dumping value to disk supports LRU and LFU
  • If use eviction, you can specify LRU or LFU, and the max keys with value in memory
  • Support Replication: Leader/Follower(i.e. Master/Slave) replica
  • I think it would support Redis Sentinel
  • I think it would support Reids Cluster. So no need for Twemproxy and Codis
  • I think it would support distributed lock, RedLock, but I think Martin Kleppmann is right
  • Support Redis Pipeline
  • Support Redis Transaction, including WATCH command
  • Support Redis Blocking
  • Support Script(LUA)
  • Support Redis Subscribe/Publish
  • Support Redis Stream
  • Support original stats for Redis including SlowLog, plus RedRock specific stats
  • Good for mass intensive writing to disk. For regular SSD, you can write new data at speed 20M/s
  • Data is compressed in disk, you only need disk volume from 10% to half of your dataset
  • When main load is for hot keys, performance is almost the same as Pure Redis, i.e. Million rps for one node
  • When coming to avarage random key visit pattern, performance maybe degrade by 1 maganitude order,I guess near Hundred Kilo rps for one node
  • Using Rocksdb library, but overload of memory in db engine is limited to tens MB
  • Keep the main logic in main thread as Redis, low level for thread switch and race risks.
  • Key/value length limit is same as Redis
  • Support multi database and can change the number

How Compile

Based on C/C++, click for details

Or

Run in docker for a sample

How Config and Run

All config parameters same as Redis, plus four added/optional RedRock config parameters

Supported Redis Features

Maybe support all Redis features, e.g. Master/Slave, Cluster, Transaction, LUA, more details.

Test Cases

You can test RedRock for all features.

Performance

I focus on the worst condition performance, more details.

Supported Redis Commands

Support all Redis commands except module commands, click for more notice

Backup and Persistence, Replication

How backup and persist the whole dataset, or use replicaton, to avoid data lose, when most(maybe 99%) values not in memory.

Stats and Tools

Some tools for stats

Peer Similar Projects

You can compare and choose other projects from peers.

redrock_old's People

Contributors

szstonelee avatar

Stargazers

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

Watchers

 avatar  avatar

redrock_old's Issues

Crash log after 5 minutes > Rocksdb string val is null in child process!

70065:M 20 Nov 2020 19:17:08.524 * RDB age 188 seconds
70065:M 20 Nov 2020 19:17:08.524 * RDB memory usage when created 761.94 Mb
70065:M 20 Nov 2020 19:17:55.551 * DB loaded from disk: 47.027 seconds
70065:M 20 Nov 2020 19:17:55.552 * Ready to accept connections
70065:M 20 Nov 2020 19:22:09.022 * 10 changes in 300 seconds. Saving...
70065:M 20 Nov 2020 19:22:09.022 * we start a rdb thread service with read-only snapshot for child process!
70065:M 20 Nov 2020 19:22:09.041 * Background saving started by pid 70138
70138:C 20 Nov 2020 19:24:32.615 * DB saved on disk
70138:C 20 Nov 2020 19:24:32.642 * RDB: 215 MB of memory used by copy-on-write
70065:M 20 Nov 2020 19:24:32.644 * rdb service exit successfully with close snapshot! rdb service thread id = -1811941632
70065:M 20 Nov 2020 19:24:32.795 * Background saving terminated with success
70065:M 20 Nov 2020 19:29:33.003 * 10 changes in 300 seconds. Saving...
70065:M 20 Nov 2020 19:29:33.003 * we start a rdb thread service with read-only snapshot for child process!
70065:M 20 Nov 2020 19:29:33.020 * Background saving started by pid 70151
rockapi write status = IO error: While pread offset 35347867 len 20413: ./redrock_rocksdb/5/000444.sst: Illegal seek
key len = 22, key = db:frq2P5xi:board_list
terminate called without an active exception
70151:C 20 Nov 2020 19:29:33.600 # Rocksdb string val is null in child process!


=== REDIS BUG REPORT START: Cut & paste starting from here ===
70151:C 20 Nov 2020 19:29:33.600 # === ASSERTION FAILED ===
70151:C 20 Nov 2020 19:29:33.600 # ==> rdb.c:1021 'rockVal' is not true
70151:C 20 Nov 2020 19:29:33.600 # (forcing SIGSEGV to print the bug report.)
70151:C 20 Nov 2020 19:29:33.600 # Redis 999.999.999 crashed by signal: 11
70151:C 20 Nov 2020 19:29:33.600 # Crashed running the instruction at: 0x55a2d9854d9f
70151:C 20 Nov 2020 19:29:33.600 # Accessing address: 0xffffffffffffffff
70151:C 20 Nov 2020 19:29:33.600 # Failed assertion: rockVal (rdb.c:1021)

Ubuntu 20 setup following the doc

zlibstd-dev is present, yet we get:

    LINK redis-server
g++: error: ../deps/staticlib/libz.a: No such file or directory
g++: error: ../deps/staticlib/libbz2.a: No such file or directory
g++: error: ../deps/staticlib/libsnappy.a: No such file or directory
g++: error: ../deps/staticlib/liblz4.a: No such file or directory
g++: error: ../deps/staticlib/libzstd.a: No such file or directory

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.