# RocksDB

RocksDB is a high performance embedded database for key-value data. It is a fork of Google's LevelDB optimized to exploit multi-core processors (CPUs), and make efficient use of fast storage, such as solid-state drives (SSD), for input/output (I/O) bound workloads. It is based on a log-structured merge-tree (LSM tree) data structure. It is written in C++ and provides official language bindings for C++, C, and Java. Many third-party language bindings exist. RocksDB is free and open-source software, released originally under a BSD 3-clause license. However, in July 2017 the project was migrated to a dual license of both Apache 2.0 and GPLv2 license. This change helped its adoption in Apache Software Foundation's projects after blacklist of the previous BSD+Patents license clause.
RocksDB is used in production systems at various web-scale enterprises including Facebook, Yahoo!, and LinkedIn.

## Features

RocksDB, like LevelDB, stores keys and values in arbitrary byte arrays, and data is sorted byte-wise by key or by providing a custom comparator.
RocksDB provides all of the features of LevelDB, plus:
* Transactions
* Backups and snapshots
* Column families
* Bloom filters
* Time to live (TTL) support
* Universal compaction
* Merge operators
* Statistics collection
* Geospatial indexing
and others.
RocksDB is not an SQL database (although MyRocks combines RocksDB with MySQL). Like other NoSQL and dbm stores, it has no relational data model, and it does not support SQL queries. Also, it has no direct support for secondary indexes, however a user may build their own internally using Column Families or externally. Applications use RocksDB as a library, as it provides no server or command-line interface.

## History

RocksDB was created at Facebook by Dhruba Borthakur in April 2012, as a fork of LevelDB with the initial stated goal of improving performance for server workloads.

## Integration

As an embeddable database, RocksDB can be used as a storage engine within a larger database management system (DBMS). For example, Rockset uses RocksDB mostly for analytical data processing.

### Alternative backend

The following projects have been started to replace or offer alternative storage engines for already-established database systems with RocksDB:

#### ArangoDB

ArangoDB has added RocksDB to its previous storage engine ("mmfiles"). RocksDB is be the default storage engine since ArangoDB 3.4.

#### Cassandra

Cassandra on RocksDB can improve the performance of Apache Cassandra significantly (3–4 times faster in general, 100 times faster in some use-cases). The Instagram team at Facebook developed and open-sourced their code, along with benchmarks of their performance results.

#### MariaDB

MariaDB can use the MyRocks storage engine (which is forked from RocksDB) since MariaDB 10.2.5 (Alpha status) and stable since MariaDB 10.2.16 in 2018.

#### MongoDB

The MongoRocks project provides a storage module for MongoDB where the storage engine is RocksDB.
A related program is Rocks Strata, a tool written in Go, which allows managing incremental backups of MongoDB when RocksDB is used as the storage engine.

#### MySQL

The MyRocks project created a new RocksDB-based storage engine for MySQL. In-depth details about MyRocks were presented at Percona Live 2016.

#### Oxigraph

Oxigraph is a graph database implementing the SPARQL standard, based on RocksDB

#### UKV

The UKV project allows users to use RocksDB on par with LevelDB as the underlying key-value store. It represents a shared abstraction for create, read, update and delete (CRUD) operations common to every storage engine. It augments it with structured bindings for several high-level languages, including Python, Java, and Go.

### Embedded

The following database systems and applications have chosen to use RocksDB as their embedded storage engine:

#### Ceph's BlueStore

The Ceph's BlueStore storage layer uses RocksDB for metadata management in OSD devices.

#### Apache Flink

Apache Flink uses RocksDB to store checkpoints.

#### FusionDB

FusionDB uses RocksDB as its storage engine for XML, Key/Value, and JSON.

#### LogDevice LogsDB

LogDevice's LogsDB is built atop RocksDB.

#### Kafka Streams

Kafka Streams uses RocksDB for its state stores.

#### Manhattan

The Manhattan Distributed Key-Value Store has used RocksDB as its primary engine to store Twitter data since 2018.

#### Rockset

The Rockset service that is used for operational data analytics uses RocksDB as its storage engine.

#### SSDB

The ssdb-rocks project uses RocksDB as the storage engine for the SSDB NoSQL Database.

#### TiDB

The TiDB project uses RocksDB as its storage engine.

#### YugabyteDB

The YugabyteDB database uses a modified version of RocksDB as part of its DocDB storage engine.

## Third-party language bindings

Third-party programming language bindings available for RocksDB include:
* C
* C#
* Chicken Scheme
* D
* Elixir
* Erlang
* Go
* Haskell
* Java
* Kotlin
* Node.js
* Nim
* Objective-C, and Swift
* OCaml
* Perl
* PHP
* Prolog
* Python
* Ruby
* Rust