B-tree vs LSM tree
A B-tree updates pages in place, so each write can cost random disk work. An LSM tree appends writes to a log and merges them later. With 6,000 metric writes/s on 1 vCPU, the B-tree store falls behind and the LSM store keeps p99 near 25 ms.
5 MB/s · logs kept on the host · disk full in 33 minutes
Index · 4 pages read per query · disk writes per insert: 2
Case 1
One stream appends 6,000 metric values/s. A catalog serves 4,000 indexed reads/s. Each store has 1 vCPU, and both need p99 under 100 ms.
| Measure | Goal | B-tree for both | LSM for metrics |
|---|---|---|---|
| p99 latency (Metrics) | under 100 ms | 10.1 s Fail | 25 ms Pass |
| p99 latency (Catalog) | under 100 ms | 25 ms Pass | 25 ms Pass |
| Monthly cost | 16 USD/mo | 16 USD/mo | |
| Error rate | 56.1% | 0% |