db nugget (3): in-mem databases do not always lose data upon restart

Arpit Bhayani

Arpit Bhayani

Aug 27, 2025 • 2 min read


db nugget (3): in-mem databases do not always lose data upon restart.

almost all major in-mem databases have a tunable parameter that allows the database to durably store the data on the disk and load it during boot up. here are different ways to implement durability; we start with the most common

write-ahead logging: every transaction is first written to a sequential log on disk before being applied to memory, enabling replay during recovery.

snapshotting: periodic full dumps of the entire in-memory dataset to disk, creating point-in-time recovery checkpoints.

multi-tier storage: frequently accessed data stays in memory while less active data gets pushed to disk-based storage tiers.

replication: synchronous or asynchronous copying of data to multiple nodes, where durability comes from redundancy across machines.

nvme: using non-volatile memory (battery-backed) helps persist RAM contents during power failures.

memory-mapped files: mapping disk files directly into virtual memory space, letting the OS handle persistence transparently.

durability is critical because in-memory databases often store business-critical data or a high cache miss rate (during cold start) can take down the origin.

the trade-off is performance versus durability guarantees - more frequent persistence operations slow down write performance but reduce potential data loss windows. so, picking one way over the other depends on your usecase.

hope this helps.

Arpit Bhayani

Principal Engineer II at Razorpay - building Agent Studio, Ex-staff engg at GCP Memorystore & Dataproc, Creator of DiceDB, ex-Amazon Fast Data, ex-Director of Engg. SRE and Data Engineering at Unacademy. I spark engineering curiosity through my no-fluff engineering videos on YouTube and my courses