Write-Ahead Log
How RocksDB makes every write durable before acknowledging it
How RocksDB makes every write durable before acknowledging it
RAM is volatile — every crash loses all buffered writes
empty
Simulate
Why is RAM volatile?
DRAM stores bits as electrical charge in capacitors. No power → charge drains → all bits flip to zero. This happens in milliseconds.
The MemTable lives entirely in process memory. The kernel has no record of its contents. Once the process dies, that memory is gone.
The MemTable absorbs writes at RAM speed, but RAM is volatile — any crash, OOM kill, or power loss destroys all buffered writes with no possibility of recovery. A database that loses acknowledged writes is broken. We need a way to make every write durable before telling the client it succeeded.
The solution is to write to disk first. But disk writes are slow — unless we choose the fastest possible disk operation: a sequential append.