Try
↑ ↓ move↵ openesc close
In this lesson · topic 3 of 7
  1. 1. Random writes are the expensive kind
  2. 2. Memtable, SSTables and compaction
  3. 3. Run leveled and tiered on the same writes
  4. 4. What each policy costs you
  5. 5. Why reads cost more here
  6. 6. When compaction cannot keep up
  7. 7. Memtables, runs and amplification

Topic 3

Run leveled and tiered on the same writes

8 min read

Same writes, two policies

The lab sends 100 writes a tick into a memtable of 200 entries. The bars show the sorted files on disk by level. Below them are write, read and space amplification, and two charts that follow them as the store grows.

Leveled compaction keeps one file per level, and each level is a multiple of the one above. Tiered compaction lets several files of a similar size gather, then merges them all. The size ratio sets the multiple, or how many files gather.

Predict before you press play

You switch from leveled to tiered compaction with the same ratio. Which numbers go down?

writes 20,000 of 40,000Leveled ratio 410,000 distinct keys

Sorted runs on disk

level 1level 2level 3

Each bar is one sorted file, drawn in proportion to its entries. Newer data sits in the upper levels.

write amplification
7.1x
read amplification
2.5 runs
worst miss
3 runs
space amplification
1.31x
compactions
122
flushes
99
Entries written to disk per user write
Entries written to disk per user write. Text version available below the chart.0x3x5x8x10x10010,10020,000writesx
Runs on disk, and stored entries per live key
Runs on disk, and stored entries per live key. Text version available below the chart.0.01.32.53.85.010010,10020,000writesruns, x

Full-page version with guided experiments: LSM compaction lab.

Things to try

  1. Read the three numbers with leveled compaction, then switch to tiered.
  2. With tiered, raise the ratio from 4 to 8.
  3. Cut distinct keys to 2000 and compare space amplification under each policy.
  4. Under leveled, raise the ratio and watch the number of levels fall.
  5. Watch the runs chart. Tiered saws up and down as merges happen. Leveled stays low.

The full-page lab also has guided experiments.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms