Unit 10 of 12 · about 4 hours · derive, measure

Read, write and space amplification and their measurement

Throughput and latency numbers are effects. Amplification ratios are the cause, and they predict how each engine behaves before you benchmark it.

You'll be able to

  • Define read, write and space amplification as ratios over user bytes.
  • Derive page-level write amplification for B-trees and level-driven amplification for LSM trees.
  • Measure throughput and latency on your store and explain the result from amplification evidence.

Covers

Read amplificationWrite amplificationSpace amplificationLatency, throughput and amplification measurement
1

Read

In this order, only the parts listed

0 of 2 done

  1. HLD Handbook amplification trade-offsHLD Handbook - Storage Engines and Data Structures

    The TL;DR impossibility statement with the B-tree 16-256x and LSM 10-30x write amplification ranges, the B-tree versus LSM write-path diagram, and Trade-offs

    Treat the vendor migration numbers as reported case figures, never as targets. Derive your own ratios in Reproduce.

  2. B-tree versus LSM performance detailDDIA 2e - Chapter 4 Storage and Retrieval

    Chapter 4, Comparing B-Trees and LSM-Trees, printed pp. 129-131: read paths, Bloom filter limits on ranges, write stalls with backpressure, and sequential versus random writes

2

Focus on

  • Write amplification is device bytes per user byte. Read amplification is bytes read per byte requested. Space amplification is disk bytes per live byte.
  • A 100-byte update rewriting a 16 KiB page costs about at page level before batching. Batching several updates per flush lowers the observed ratio without changing the mechanism.
  • Leveled LSM compaction commonly costs 10-30x with about 10% space overhead. Tiered compaction writes less but holds more overlapping runs and transiently doubles disk use.
  • You cannot minimize all three at once. Report all three ratios with the workload beside them; a single ratio without workload context proves nothing.
Common mistakes · 3
  • Quoting one amplification number as the engine constant. Each ratio moves with entry size, batching, level count and workload mix.
  • Comparing benchmark numbers across different workloads. Amplification explains the gap only when both sides state entry sizes and read-write mix.
  • Crediting Bloom filters for range-query speed. They skip point reads only; ranges still open every overlapping run.
3

Try it yourself

Closed-book, before checking anything

Derive page-level write amplification for a 100-byte update in a 16 KiB page: , about . Then size 200,000 writes per second of 200-byte records: 40 MB/s user data, so 10-30x compaction writes 400 MB/s to 1.2 GB/s to the device.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.What are the three amplification ratios as formulas?Answer

    Write amplification is device write bytes over user write bytes. Read amplification is bytes read over bytes requested. Space amplification is stored bytes over live bytes.

  2. 2.A B-tree batches 8 updates of 100 bytes into one 16 KiB page flush. What is the observed write amplification?Answer

    About , or 20x. Batching amortizes the page rewrite across updates; the unbatched page-level cost stays near 164x.

  3. 3.An LSM reports 20x write amplification at 40 MB/s ingest. What device bandwidth does compaction consume?Answer

    About 800 MB/s. The ratio multiplies user bytes into device bytes regardless of which level does the rewriting.

  4. 4.Why can two engines with equal write amplification show different p99 read latency?Answer

    Because read amplification differs. The LSM may check several runs per read while the B-tree touches one page per level, so equal write cost coexists with unequal read cost.

5

Practice

You're done when

You derive all three ratios for a new entry size and workload without notes and explain a measured latency from them.

Only when you can do this without notes.

Leads to

Notes

Resources · 2 for this unit, 11 more in the section
  • DDIA 2e - Chapter 4 Storage and RetrievalMartin Kleppmann and Chris Riccomini · required

    Read "Storage and Indexing for OLTP" (log-structured storage, B-trees, their comparison and secondary indexes) and "Data Storage for Analytics" (column-oriented storage). Its Bloom filter, tombstone and write-ahead log coverage is brief, so take those from OSTEP and The Internals of PostgreSQL. Build a workload decision table, then connect each claim to a measurement from your small store.

  • HLD Handbook - Storage Engines and Data StructuresHLD Handbook · required

    Read Part 0 data structures plus Part 4 storage engines and OLTP versus OLAP. Use its exercises for comparison, while the CMU project and local fault tests remain the implementation evidence.

Also in this section

  • CMU 15-445 - Storage, Index and Recovery SequenceCarnegie Mellon Database Group · primary

    Follow Fall 2025 lectures 3 to 10 and 21 to 22. Do the BusTub projects from tag v20251119-2025fall (https://github.com/cmu-db/bustub/tree/v20251119-2025fall): P1 (ARC replacer, disk scheduler and buffer pool manager) and P2 (B+ tree with a leaf tombstone buffer), with P0 (Count-Min Sketch) as the C++ warm-up. Tests ship with a DISABLED_ prefix to remove, and GCC 15 needs -DCMAKE_CXX_FLAGS="-include cstdint" at configure time. Use the storage and recovery homework for WAL reasoning, and keep C++ scope bounded to storage and recovery.

  • Hypothesis - Stateful TestingHypothesis · support

    Use RuleBasedStateMachine with rules, bundles and invariants to drive your store and a dictionary model with the same random operation sequences, and check the machine catches a planted bug before trusting a pass.

  • Building Distributed Systems - The Logger and IndexesBuild Distributed Systems · optional

    Only the first three tasks are free (a write-ahead log, its recovery and log segments). Tasks are graded in the browser after login, so treat a pass as a drill and keep your local harness as the evidence.

  • The Internals of PostgreSQL - Buffer Manager, WAL and RecoveryHironobu Suzuki · support

    Read Chapter 1 Sections 1.2 to 1.4 (heap pages and tuples), Chapter 8 (buffer manager and dirty-page flushing) and Chapter 9 Sections 9.1 to 9.8 (WAL segments, XLOG records, checkpoints and recovery). Compare each mechanism with your simplified store. The site is revised often, so note the date you read it.

  • PostgreSQL 18 Documentation - WAL Configuration and InternalsPostgreSQL Global Development Group · support

    Read "WAL Configuration" (checkpoints and the redo point crash recovery starts from), "WAL Internals" and "Reliability" for the official, versioned statement of the write-ahead and durability contract.

  • Operating Systems: Three Easy Pieces - Crash Consistency and Data IntegrityRemzi and Andrea Arpaci-Dusseau · required

    Read Chapter 42 (FSCK and journaling: the crash scenarios, data and metadata journaling and their write order) and Chapter 45 (data integrity: checksums, misdirected and lost writes, scrubbing; https://pages.cs.wisc.edu/~remzi/OSTEP/file-integrity.pdf). Turn each crash scenario into an injection point in your store.

  • ARIES: A Transaction Recovery Method (Mohan et al., 1992)ACM TODS (Stanford course copy) · support

    Read the introduction, the overview and restart processing (analysis, redo by repeating history, undo) and the page LSN rule. The rest is 1992 storage detail beyond this section.

  • Build Your Own RedisBuild Your Own · optional

    Use the persistence and data-structure portions only if a second implementation is needed to cement parsing, indexing or append-log behavior. Do not replace the crash-tested stage artifact with tutorial completion.

  • Replicated Log and Stream Processor - Storage SliceRoadmap-Final · support

    Implement checksummed segments, indexes, acknowledgement states, recovery, retention and atomic metadata changes. Preserve every crash schedule and corrupted artifact needed to reproduce a failure.

  • Apache Parquet File FormatApache Software Foundation · support

    Read the File Format layout (row groups, column chunks, footer metadata) and the Page Index page (ColumnIndex and OffsetIndex with per-page min and max values for page skipping). Use it only for file layout and skipping; it does not cover table metadata or catalogs.

  • Linux man-pages: fsyncLinux man-pages project · support

    Read the DESCRIPTION for what fsync and fdatasync guarantee and the directory-sync requirement for new file names, and the ERRORS section for what an EIO from write-back can refer to.