Library / Papers
Bitcask: a log-structured hash table for fast key/value data
The design note behind Bitcask: append-only files, an in-memory key directory and merging.
By Justin Sheehy and David Smith · Basho Technologies · Added 2026-10-12
All content belongs to Justin Sheehy and David Smith / Basho Technologies. We only link to it and give credit. Report a problem
Learn this paper
About 37 min left. Your work is saved as you go.
What you are about to study
Basho Technologies wrote this paper. Read the abstract and headings first. It assumes you are comfortable with distributed systems.
Ideas you will meet
- Storage Engines
- Write-ahead logs, B-trees and LSM-trees.
What we already know about this
Our own lessons on these ideas. Read them here before you start, so it makes sense.
Storage, Queues and Real-time · 11 minBitcask: a tiny log-structured key-value storeHow an append-only data file plus an in-memory key directory gives one-seek reads and fast writes, how deletes and merges work, and the limits of the design.Read here
The idea in one paragraph
Keep all data in append-only files. Never modify old bytes. Keep, in memory, a hash table called the keydir that says where the latest value of each key lives. A write appends to the file and updates the keydir. A read looks up the keydir and does one disk read at the recorded position.
100%Figure SDA-SQR-01-1 · Bitcask write and read paths · © forcsguy.com
The record format
Each record in a data file looks like: CRC, timestamp, key size, value size, key, value. The CRC lets the engine detect torn or corrupt writes after a crash. When the active file reaches a size limit it is closed (becomes immutable) and a new active file starts.
Deletes and updates
- An update simply appends a newer record; the keydir points to it. The older record becomes garbage.
- A delete appends a special tombstone record and removes the key from the keydir.
Merging (compaction)
Over time the files fill with stale records. A merge process reads the immutable files, keeps only the latest live record per key, writes them into new files and deletes the old ones. It can run in the background without blocking reads and writes.
100%Figure SDA-SQR-01-2 · Merge reclaims space · © forcsguy.com
Recovery
On start, the keydir is gone and must be rebuilt. Reading every record of every file works but is slow for large stores. Hint files hold just the keys and positions for each data file, so recovery reads much less data. Torn writes at the end of the last file are detected by the CRC and truncated.
Strengths and limits
Strength Limit Very fast writes: sequential appends Every live key must fit in RAM Reads need one seek No range scans: the keydir is a hash table, not ordered Simple crash recovery from an append-only log Merge needs spare disk space and I/O Easy backups: files are immutable Single writer per store When keys do not fit in memory or you need ordered scans, an LSM-tree (memtable, sorted files, compaction) is the usual answer, as in RocksDB. When you need transactions and ad hoc queries, use a database.
Real-world reading
Go deeper on this
A path through videos, articles, other case studies and code on the same ideas as Bitcask: a log-structured hash table for fast key/value data.
Warm upGet the vocabulary first.
Books · Free from the author
Readings in Database Systems (the Red Book)
Essays and papers on how database systems are built, with an introduction to each, free online from the editors.
Red BookAdvanced
Books
Database Internals
How storage engines and distributed databases work, from B-trees and LSM-trees to consensus and replication.
O'ReillyAdvanced
WatchHow others solve the same problem, on video.
Videos belong to their creators and play from YouTube. More on YouTube (opens in a new tab)
ReadEngineers explain it in their own words.
Papers · Read here
Amazon Aurora: Design Considerations for High Throughput Cloud-Native Relational Databases (paper)
Why Aurora moves the redo log to a distributed storage layer, so replication and crash recovery become cheap.
Amazon Web ServicesAdvanced
Papers · Read here
Bigtable: A Distributed Storage System for Structured Data (paper)
Google's wide-column store: tablets split by key range, a commit log plus sorted files on disk, and the design later copied by HBase and Cassandra.
GoogleAdvanced
See it in another companyThe same ideas, a different system.
Case Studies · Read here
Inside the Magic Pocket
How Dropbox built its own exabyte-scale block storage, including durability and cost choices.
DropboxAdvanced
Case Studies
HaloDB: Embedded Key-Value Storage Engine at Yahoo
yahoodevelopers: By Arjun Mannaly, Senior Software Engineer At Oath, multiple ad platforms use a high throughput, low latency distributed key-value database that runs in data centers all over the world. The database s...
YahooAdvanced
Read the codeSee how it looks when it is real.
GitHub
ClickHouse
A column-oriented analytics database.
GitHubAdvanced
GitHub
LevelDB
A small, readable LSM-tree key-value store, a good first storage engine to study.
GitHubAdvanced
Keep learning
Loading community…