QA
Senior LevelSystem Design & Architecture

What is Write Amplification in Log-Structured Merge (LSM) Trees?

❓ Interview Prompt: Explain LSM-Trees (Log-Structured Merge Trees), MemTable, SSTables, SSTable Compaction, and Write Amplification calculations.

Log-Structured Merge (LSM) Trees optimize write performance by buffering writes in an in-memory MemTable and flushing them sequentially to SSTables on disk:

Write Amplification:

β€’
Occurs when data is written to disk multiple times due to background SSTable Compaction merges.
β€’
Write Amplification Factor (WAF): Ratio of total bytes written to underlying storage vs bytes written by client. High WAF wears out SSD flash memory and consumes disk I/O bandwidth!

Code Implementation Example

markdown
LSM-Tree Write Path and Compaction:

[Client Write] ──> [MemTable (RAM)] ──(Flush)──> [Level 0 SSTable (Disk)]
                         β”‚                                β”‚
                   (Write-Ahead Log)            (Background Compaction)
                                                          β”‚
                                                          β–Ό
                                                [Level 1 SSTable (Disk)]
πŸ’‘LSM-Tree write path and background SSTable compaction.
🎯 Interview Key Takeaway

LSM-Trees provide fast sequential writes, but background compaction causes Write Amplification that must be monitored.

#System Design#LSM-Tree#Write Amplification#SSTables#Senior
Back to all System Design & Architecture Questions→

More System Design & Architecture Interview Questions

Beginner LevelSystem Design & Architecture

Explain the CAP Theorem and PACELC Theorem with real-world database examples.

Beginner LevelSystem Design & Architecture

What is Vertical Scaling (Scale Up) vs Horizontal Scaling (Scale Out)?

Beginner LevelSystem Design & Architecture

How do Load Balancers distribute traffic (Round Robin, Least Connections, IP Hash)?