Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis vs RocksDB

Tags:

redis

rocksdb

I have read about Redis and RocksDB, I don't get the advantages of Redis over RocksDB.

I know that Redis is all in-memory and RocksDB is in-memory and uses flash storage. If all data fits in-memory, which one should I choose? do they have the same performance? Redis scales linearly with the number of CPU's? I guess that there are others differences that I don't get.

I have a dataset which fits in-memory and I was going to choose Redis but it seems that RocksDB offers me the same and if one day the dataset grows too much I wouldn't have to be worried about the memory.

like image 907
Guille Avatar asked Aug 05 '15 11:08

Guille


People also ask

What is RocksDB good for?

RocksDB can be used by applications that need low latency database accesses. Possibilities include: A user-facing application that stores the viewing history and state of users of a website. A spam detection application that needs fast access to big data sets.

Which databases use RocksDB?

RocksDB is used in production systems at various web-scale enterprises including Facebook, Yahoo!, and LinkedIn.

Does Cassandra use RocksDB?

Instagram Supercharges Cassandra with a Pluggable RocksDB Storage Engine. To boost the performance of a mission-critical instance of Cassandra, Instagram engineers replaced the storage engine of this Java-based distributed open source database with a faster C++-based one from another database, RocksDB.

Is RocksDB persistent?

RocksDB is an embeddable persistent key-value store for fast storage.


4 Answers

They have nothing in common. You are trying to compare apples and oranges here.

Redis is a remote in-memory data store (similar to memcached). It is a server. A single Redis instance is very efficient, but totally non scalable (regarding CPU). A Redis cluster is scalable (regarding CPU).

RocksDB is an embedded key/value store (similar to BerkeleyDB or more exactly LevelDB). It is a library, supporting multi-threading and a persistence based on log-structured merge trees.

like image 53
Didier Spezia Avatar answered Oct 22 '22 21:10

Didier Spezia


While Didier Spezia's answer is correct in his distinction between the two projects, they are linked by a project called LedisDB. LedisDB is an abstraction layer written in Go that implements much of the Redis API on top of storage engines like RocksDB. In many cases you can use the same Redis client library directly with LedisDB, making it almost a drop in replacement for Redis in certain situations. Redis is obviously faster, but as OP mentioned in his question, the main benefit of using RocksDB is that your dataset is not limited to the amount of available memory. I find that useful not because I'm processing super large datasets, but because RAM is expensive and you can get more milage out of smaller virtual servers.

like image 27
Will Krause Avatar answered Oct 22 '22 21:10

Will Krause


  1. Redis, in general, has more functionalities than RocksDB. It can natively understand the semantics of complex data structures such as lists and arrays . RocksDB, in contrast, looks at the stored values as a blob of data. If you want to do any further processing, you need to bring the data to your program and process it there (in other words, you can't delegate the processing to the database engine aka RocksDB).
  2. RocksDB only runs on a single server. Redis has a clustered version (though it is not free)
  3. Redis is built for in-memory computation, though it also support backing the data up to the persistent storage, but the main use cases are in memory use cases. RocksDB by contrast is usually used for persisting data and in most cases store the data on persistent medium.
  4. RocksDB has a better multi-threaded support (specially for reads --writes still suffer from concurrent access).

Many memcached servers use Redis (where the protocol used is memcached but underlying server is Redis). This doesn't used most of Redis's functionality but is one case that Redis and RocksDB both function similarly (as a KVS though still in different context, where Redis based memcached is a cache but RocksDB is a database, though not an enterprise grade one)

like image 15
Reza Sadri Avatar answered Oct 22 '22 21:10

Reza Sadri


@Guille If you know the behavior of hot data(getting fetched frequently) is based of time-stamp then Rocksdb would a smart choice, but do optimize it for fallback using bloom-filters .If your hot data is random ,then go for Redis .Using rocksDB entirely in memory is not generally recommended in log-structured databases like Rocksdb and its specifically optimized for SSD and flash storage .So my recommendation would be to understand the usecase and pick a DB for that particular usecase .

like image 3
sumit jha Avatar answered Oct 22 '22 22:10

sumit jha