KatInterview

Log-Structured Storage: Replication, Recovery, and MVCC

System DesignModel answer
HardModel answerSystem Designdistributed-systemsdatabasesstorage-engines

Last updated

Describe how log-structured databases decouple compute from storage, use quorum-based replication, achieve fast recovery, and handle multi-version concurrency control.

Modern distributed databases separate the compute tier from the storage tier by shipping only log records to storage nodes, rather than flushing complete data pages. This architecture reduces write amplification and enables highly available, low-latency operations.

Your task is to explain how this log-centric architecture works, covering four key areas:

Part 1: Log-Centric Storage Model

Describe how a log-based storage system differs from traditional page-oriented databases. What does the compute node send to storage, and what work is moved out of the critical write path? How does the storage layer reconstruct pages when they're needed?

Part 2: Quorum-Based Replication

Consider a system that replicates each storage segment across 6 nodes (2 per availability zone, spanning 3 zones). Explain how quorum writes work in this setup. What are reasonable quorum sizes for reads and writes, and why? How does this design tolerate availability zone failures while maintaining write availability?

Part 3: Fast Recovery Mechanism

Compare the recovery process after a crash between traditional log-replay systems and log-structured storage. Why can the log-structured approach resume operations in seconds rather than minutes? What bookkeeping is required to identify a consistent recovery point?

Part 4: Multi-Version Concurrency Control

Explain how physical page versioning at the storage layer interacts with logical row-level MVCC at the compute layer. Does moving to log-structured storage eliminate the need for garbage collection or vacuum processes? Why or why not?

Throughout your answer, contrast this design with conventional architectures where the database engine writes full pages to disk during checkpoints.

Hints

Hint 1

Think about what happens to dirty pages in the buffer pool when the storage layer can reconstruct them from logs

Hint 2

Consider the tail latency benefits of waiting for only K out of N acknowledgments

Hint 3

Recovery speed depends on whether redo work was deferred or done continuously

Hint 4

Physical page versioning and logical transaction visibility are orthogonal concerns