rocksdb基于Log-Structured Merge (LSM) Trees,分析rocksdb存储引擎的读写空间放大比例,即主要对LSM Trees结构进行分析,相关基础概念以论文A Comparison of Fractal Trees to Log-Structured Merge (LSM) Trees中的定义为准。
先来看基础概念:
1> Read amplification is the number of I/O’s required to satisfy a particular query.
读放大:一次指定查询所需的IO操作数目。
2> Write amplification is the amount of data written to storage compared to the amount of data that the application wrote.
写放大:实际写入磁盘的数据大小比上用户期望程序写入的数据量。
3> Space amplification is the space required by a data structure can be inflated by fragmentation or requirements for temporary copies of the data.
空间放大:存储采用的数据结构因分裂或临时数据拷贝造成的磁盘空间占用放大。
LSM Trees有leveled和size-tiered两种形式:
1. Leveled LSM Trees
从第Level 0到Level h(h>1)所在层数据大小按k倍逐层增长,例如k=10,总计7层时,对应level 6有不超过10TB大小的数据。
假定数据集总大小为N,增长因子