Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The Hitchhiker’s Guide to FoundationDB and Storage Layers

“Don’t Panic.”

This guide assumes you have seen a key–value store before but have never thought hard about what happens underneath. By the end you should be able to design and build your own layer on top of FoundationDB — not just copy one.


What This Guide Covers

Six chapters that take you from first principles all the way to production-grade distributed systems. Each chapter is self-contained and builds on the previous.

ChapterTopicWhat you’ll know after
1. The Storage StackB-trees, LSM-trees, WAL, buffer poolsWhy every database makes the same five trade-offs
2. FoundationDB in DepthMVCC, commit pipeline, cluster roles, simulationHow FDB achieves correctness and why it’s trusted at Apple scale
3. The Layer ConceptKey encoding, subspace pattern, atomicityHow to turn an ordered KV store into any data model
4. How Real Systems Use FDBCloudKit, mvsqlite, Document Layer, TiKVThat the patterns in this repo are battle-tested in production
5. This RepositoryThe five lab implementationsHow to navigate, run, and extend the labs
6. Reading GuidePapers, books, source code to read nextWhere to go to become a true expert

How to Read This

If you have 2 hours: Read chapters 1–3, then pick any one lab and read its Architecture Walk-through.

If you have a day: Read all six chapters, then work through all five labs in order (A-leveldb → A-sqlite → B-leveldb → B-sqlite → C-record-layer). The labs increase in conceptual complexity.

If you’re preparing for a systems interview: Focus on chapters 1–3 and the Interview Q&A sections at the end of each lab guide.

If you just want to run the code: Jump straight to Chapter 5 — This Repository for quick-start instructions, then come back to the background chapters for depth.


Core Insight

Every database is a stack of layers, each one a client of the one below. FoundationDB occupies one specific layer: ordered, transactional, distributed key-value storage. Every layer above it — SQL, document model, LevelDB API, SQLite page store, record layer — is a pure encoding problem. Learn the encoding and you understand the database.

That is what this guide teaches.