Log structured merge tree (LSM tree)
a balanced tree + SS(sorted string) tables + periodical merging + crash recovery log -> LSM tree
- Create an in-memory balanced tree like an AVL tree; or red-black tree
- Append write to the tree and crash recovery log
- Periodically flush the tree to a file and discard crash-log. There will be multiple files, all sorted.
- These sorted string tables are called SS Tables. Periodically merge them in the background
Pro
Lower write amplification, better disk life
Higher throughput
Localized data, less unused disk space
Better compression, smaller files
Con
Less stable response times in higher percentiles
Compaction costs
If compaction is not configured well, it may get behind the writes, leading to a disk full,
and slower writes due to checking more segments
So monitor well