Level 0: Orientation & prerequisites · L0.2 OS & hardware basics for architects
Durability: when is data really saved?
Explain page cache, fsync and why write() is not durability.
12 min · Free
What you take away
- write() copies into the OS page cache and returns; the data is in volatile RAM, not on the drive.
- fsync() is the call that asks for it to be on stable media, and it costs ~0.5–2 ms even on NVMe.
- Databases fsync a write-ahead log, not the data files, and batch many commits into one fsync (group commit).
- Durability is a choice with a price: buffering is fast and loses recent writes; fsync-per-commit is safe and caps a single writer at a few hundred commits per second.
How the class is laid out
- The problem
- The simple version
- The layers between your code and the platter
- What that costs, and what databases do about it
- Memory hierarchy
- Processes and threads
- Async I/O
- Durability
- Check your understanding