Skip to content
← All writing

I BUILT A DATABASE FROM SCRATCH IN RUST. HERE'S EVERYTHING THAT WENT WRONG.

· Pulkit Saraf

ferrokey is a small embedded key-value database I built in Rust, with no runtime dependencies. The goal was an engine you could read end to end and still trust to recover committed writes after a crash.

The existing options were more than I wanted for this project. SQLite brings a relational engine, RocksDB brings C++, and sled has a much larger surface to understand. I wanted something small enough to follow every page split and every write to disk.

That meant building the storage machinery too: fixed-size pages, a B-tree, and a write-ahead log with checksums. The interesting part is the ordering. When a write becomes durable determines what recovery can safely replay after the process stops halfway through.

Read the full article on X ↗