Embedded and networked key-value stores, from LMDB and RocksDB to Redis and FoundationDB.
BadgerDB is an embedded, persistent key-value store written in pure Go by the Dgraph team. Designed in 2017 to address the problem that LevelDB- and…
FoundationDB is a distributed, ordered key-value store with strictly serializable multi-key ACID transactions, used as a foundation for higher-level data models.
LMDB is an embedded, memory-mapped, B+tree key-value store written in C by Howard Chu of OpenLDAP. It is one of the fastest embedded databases ever built…
LevelDB is a fast, embedded key-value store written by Sandy Ghemawat and Jeff Dean at Google. It is a single-process library — no server, no network…
Memcached is a high-performance, distributed in-memory key-value cache designed in 2003 by Brad Fitzpatrick at LiveJournal. It is the spiritual ancestor of…
Redis ( RE mote DI ctionary S erver) is the most-deployed NoSQL system in the world. Created by Salvatore Sanfilippo in 2009, it is an in-memory…
RocksDB is a high-performance embedded key-value database, originally forked from Google's LevelDB by Facebook (Meta) in 2012. It keeps LevelDB's LSM-
bbolt is an embedded, pure-Go B+tree key-value store, originally written by Ben Johnson as BoltDB and now maintained by the etcd team as bbolt . It is to Go…
A key-value store maps opaque keys to opaque values and exposes a small API: get, put, delete, and in ordered stores, range scans by key prefix. That narrow interface is what makes them fast and composable; many larger databases are built on top of one. The eight stores in this section fall into two groups. Embedded stores (LevelDB, RocksDB, BadgerDB, LMDB, bbolt) are libraries linked into a single process with no server or network hop. Networked stores (Redis, Memcached, FoundationDB) run as servers shared by many clients, ranging from a pure cache to a distributed transactional database.
Embedded stores differ mainly in their on-disk structure. LSM-tree engines (LevelDB, RocksDB, BadgerDB) append writes to a log and memtable and merge sorted files in the background, giving high write throughput at the cost of compaction work and some read amplification; BadgerDB separates large values from keys to reduce that cost. B+tree engines (LMDB, bbolt) update pages copy-on-write in a single file, which gives very fast reads, simple crash safety, and one writer at a time. Among servers, Memcached is a volatile cache with no persistence; Redis keeps data in memory with optional persistence and rich data structures; FoundationDB distributes an ordered key space across a cluster with serializable transactions.
| Store | Type | Choose it when |
|---|---|---|
| Redis | In-memory server | Caching, sessions, rate limits, queues, leaderboards with data structures |
| Memcached | In-memory cache | Simple, multi-threaded look-aside cache with no persistence |
| RocksDB | Embedded LSM (C++) | Write-heavy storage engine inside a larger system |
| LevelDB | Embedded LSM (C++) | Small, simple embedded store; RocksDB is the usual upgrade |
| BadgerDB | Embedded LSM (Go) | Go services needing fast writes without cgo |
| LMDB | Embedded B+tree (C) | Read-heavy workloads, many readers, memory-mapped access |
| bbolt | Embedded B+tree (Go) | Go apps needing a simple transactional file store (etcd uses it) |
| FoundationDB | Distributed ordered KV | Multi-key ACID transactions across a cluster |
# Redis: networked, with TTLs and atomic counters
redis-cli SET session:42 '{"user":"kevin"}' EX 3600
redis-cli INCR rate:ip:203.0.113.7
redis-cli GET session:42
# LMDB: embedded, transactional, ordered keys
import lmdb
env = lmdb.open("/tmp/kv-demo", map_size=10 * 2**20)
with env.begin(write=True) as txn:
txn.put(b"user:001", b"alice")
txn.put(b"user:002", b"bob")
with env.begin() as txn:
cur = txn.cursor()
cur.set_range(b"user:") # ordered prefix scan
for k, v in cur:
if not k.startswith(b"user:"):
break
print(k, v)
The Redis example shows what networked stores add: expiry and atomic server-side operations shared by many clients. The LMDB example shows what embedded ordered stores add: transactions and range scans with no network hop.
See also wide-column stores.