How To Sound Like You Know RocksDB (2) 

A tale of two databases

Kai Liu
RocksDB for everyone
2 min readFeb 17, 2014

--

LevelDB: RocksDB’s predecessor

RocksDB is evolved from LevelDB. Much of LevelDB’s code and architecture still plays significant role in RocksDB. From wikipedia:

LevelDB is an open source on-disk key-value store written by Google Fellows Jeffrey Dean and Sanjay Ghemawat,who built parts of Google’s platform. Inspired by BigTable, […] under the New BSD License and has been ported to a variety of Unix-based systems, […] Android.

As we discussed, LSM was the one of the fundamental ideas behind LevelDB. Be be more precise, LevelDB is based on BigTable’s tablet implementation. BigTable wasn’t open-sourced because of its dependency on multiple Google’s internal libraries. Thus LevelDB authors, Jeff Dean and Sanjay Ghemawat, decided to build a light-weight system that resembles the BigTable’s tablet — but simpler. At first, LevelDB was famously known to be used in Chrome.

LevelDB provides a list of features that are still being supported (and enhanced) by RocksDB:

Keys and values are arbitrary byte arrays.

1. Data is stored sorted by key.
2. The basic operations are Put(key,value), Get(key), Delete(key).
3. Multiple changes can be made in one atomic batch.
4. Users can create a transient snapshot to get a consistent view of data.
5. Forward and backward iteration is supported over the data.

(Excerpted from LevelDB’s official site)

RocksDB: for fast storage environments

RocksDB’s story begins when Facebook was looking for an embedded database that could be a good candidate for databases that run on memory or flash devices. Eventually LevelDB stood out since it has best overall random read/write performance.

LevelDB was good, but not perfect, especially it wasn’t designed for production workload. These slides has well explained the evolution of RocksDB. Especially, one of its slide highlights the similarities and differences between these two databases.

RocksDB’s improvements over LevelDB.

Also, a lot of components in RocksDB were made pluggable, ie. memtable, SSTable, even the compaction algorithms etc. Another slide described the new architecture:

RocksDB’s architecture.

Next…

In the next posts, we’ll continue our tour to explore the architecture and dig deeper (well, not too deep, just right amount of depth) into the important components.

--

--

Kai Liu
RocksDB for everyone

RocksDB developer; Big fan of #Linux/#Unix, #Python; Love and hate #C++; School hater -- yet spent over 8 years in 3 universities