KatInterview

Design a Single-Node Durable Key-Value Engine

System DesignModel answer
HardModel answerSystem Designstorage-enginelsm-treewal

Last updated

Design an embeddable single-node key-value storage engine providing durability, high write throughput, crash recovery, and single-key transactions.

Provide an architectural design for a single-node, durable key-value store supporting put(key, value), get(key), and delete(key) operations.

Your proposal should cover:

  1. Target Workload & Scale Constraints: Hardware specs, throughput targets, key/value size assumptions, and explicit durability/consistency definitions.
  2. Storage Architecture & Data Layout: In-memory and on-disk data structures (e.g., WAL, MemTable, SSTables), internal block structures, and indexing/filter mechanisms.
  3. Write/Read Execution Paths: Step-by-step trace of how writes, deletes, and point reads are processed across memory and disk structures.
  4. Durability, Group Commit & Crash Consistency: Mechanics of the Write-Ahead Log (WAL), handling disk-syncing trade-offs, dealing with torn/truncated writes, and step-by-step recovery logic after an ungraceful shutdown.
  5. Garbage Collection & Data Compaction: Compaction strategies, write/read amplification trade-offs, space reclamation, and tombstone handling.
  6. Concurrency Model: Synchronization strategy for concurrent reads and writes, isolation level, and how locks or lock-free structures are utilized.
  7. Verification & Failure Injection: Strategy for testing crash consistency and data integrity.