How does the size ratio between levels change an LSM tree, and how would you tune it?
Sketch your own answer first, then compare it with the one below.
A strong answer
A larger ratio makes each level bigger relative to the one above, so there are fewer levels. In leveled compaction that means fewer levels to read, and more rewriting for each entry at each merge, since each merge pulls in a larger neighbour. In tiered compaction a larger ratio means more runs wait before a merge: cheaper writes, more runs to read.
To tune, you start from the workload mix. Measure the share of writes, point reads, misses and scans, and the space budget. Then pick a policy and ratio that put the cost where the workload can bear it, and watch compaction backlog and read latency after the change.
Adaptive designs mix policies, with tiered at small levels and leveled at the largest, so that most data sits in one run and recent data is cheap to write.
Sources
- Niv Dayan, Stratos Idreos (2018). Dostoevsky: Better Space-Time Trade-Offs for LSM-Tree Based Key-Value Stores via Adaptive Removal of Superfluous Merging.
- Niv Dayan, Manos Athanassoulis, Stratos Idreos (2017). Monkey: Optimal Navigable Key-Value Store.