Wiki: Behind the doors of key-value stores
For agents: Markdown version · Wiki index · Explore
- Speaker: Eran Gilad
- Event: Reversim Summit 2022
- Video: https://www.youtube.com/watch?v=PuyuDvWhH4E
- Transcript: /transcripts/2022/13-PuyuDvWhH4E.md
- Language: Hebrew · Type: talk · Level: intermediate
- Topics: Databases, Performance, Algorithms, Infrastructure
Written by an LLM from machine transcripts. It can contain errors. Check the transcript before you quote it.
Summary
This talk explores the internal architecture and design trade-offs of key-value stores, focusing on how different data structures manage data on disk versus in memory. The speaker breaks down five distinct design approaches, including B-Trees, LSM-Trees, and log-plus-index systems, analyzing their impact on read, write, and scan performance. Through this comparison, the audience learns how to evaluate these trade-offs to choose the right database architecture for specific application requirements.
Key points
- 1:23 A key-value store is the most basic type of database, supporting core operations such as put, get, scan, and delete.
- 3:43 Working with disk storage requires handling block devices efficiently, meaning reads and writes should be performed in large chunks rather than single bytes.
- 7:01 B-Trees organize data into wide, fixed-size nodes mapped to disk blocks, providing efficient sorted range scans and low-depth traversal.
- 16:31 LSM-Trees separate fast frequent writes in a memory table and a sequential log from slower background compaction processes across tiered disk files.
- 23:03 Separating keys from values in an LSM architecture allows smaller index structures that fit better in cache, though range scans become less efficient.
- 25:08 Log-plus-index designs keep all keys in main memory for fast gets and puts, but suffer from slow recovery times after server restarts.
- 27:22 Choosing a key-value store design always involves a trade-off between immediate write updates, scan performance, memory usage, and recovery speed.
Takeaways
- Understand that disk I/O efficiency relies on working with block-sized chunks of data rather than individual bytes.
- Evaluate whether your application prioritizes fast writes (like LSM-Trees) or fast range scans (like B-Trees).
- Consider memory constraints and recovery times when deciding whether to keep indexes in RAM or on disk.
Questions this talk answers
- What are the core performance differences between B-Tree and LSM-Tree storage engines?
- Why is sequential block I/O preferred over random access when designing disk-based databases?
- How do log-plus-index architectures impact database recovery time after a crash?
Technologies
Redis, MySQL, RocksDB, LevelDB
Tags
b-tree, data structures, databases, disk i/o, lsm-tree, performance, storage engines