Database Indexing hard
What is 'Write Amplification' in LSM-based databases?
- A The ratio of the total amount of data written to physical disk storage versus the actual amount of data specifically requested by the user application.
- B The total replication factor across a distributed database cluster, which determines how many times a single record is copied for high availability.
- C The physical size of the Write-Ahead Log (WAL) relative to the current size of the in-memory MemTable, used to calculate recovery time objectives.
- D The CPU overhead and latency penalty associated with applying high-compression algorithms to cold data stored in the low-level SSTable structures.
Answer: A. The ratio of the total amount of data written to physical disk storage versus the actual amount of data specifically requested by the user application.
In LSM-based systems, a single user write is not written once and forgotten. To keep the database efficient, background processes (Compaction) constantly read multiple SSTables, merge them to remove duplicates/deletes, and write them back as new sorted files. This means a single 1KB record might be read and written a dozen times as it moves through various levels of the database. This 'Write Amplification' can be significant (often 10-50x), consuming disk I/O bandwidth and shortening the lifespan of SSD storage devices.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- Z-Order Curves (Geohashing) map 2D data to 1D strings for indexing. What is their primary weakness?
- In-Memory databases (Hyper, HANA) often favor Adaptive Radix Trees (ART). Why?
- Log-Structured Merge (LSM) Trees (RocksDB, Cassandra) optimize for Write Throughput. How does their disk IO pattern differ from B-Trees?
- In LSM compaction strategies, 'Universal' (Tiered) compaction prioritizes what over 'Leveled' compaction?
- In LSM trees, what is 'Space Amplification'?
- Why is it generally ineffective to index a 'Low Cardinality' column like `Gender` ('Male'/'Female')?