TechCompare LogoTechCompare

RAM disk vs NVMe SSD: when putting your data in RAM makes sense

Use a RAM disk for ephemeral, performance-critical data that can be regenerated. Don't use it for anything you'd be upset to lose. For most workloads, the OS page cache already keeps frequently accessed files in RAM automatically, making an explicit RAM disk unnecessary.

A RAM disk turns system memory into a block device with roughly 80 ns latency and 100+ GB/s bandwidth, compared to an NVMe SSD's 100 µs latency and 7 GB/s bandwidth. For random access, a RAM disk is 1,000x faster. The trade-off: everything in a RAM disk disappears when the machine loses power or reboots.

By TechCompare · Updated

Hardware tier
Storage
Persistent storage devices
Topic focus
RAM disk vs NVMe
ramdisk-vs-nvme

How this is calculated

RAM disks make sense for workloads where the data is either ephemeral (compile artifacts, temporary database tables, video rendering scratch space) or easily regenerated from persistent storage (caches, indexes). Linux's tmpfs creates a RAM-backed filesystem that can swap to disk under memory pressure. Windows has a built-in RAM disk via ImDisk or third-party tools. For databases, putting tempdb or a read replica entirely in RAM can dramatically improve query performance. Modern build systems (Bazel, Buck2) use RAM disks for compile caches by default. If your data can be lost without consequence and you need maximum random I/O, a RAM disk is the right tool.

Verdict

The win is real when the workload is ephemeral. RAM disks run at 80 ns latency with 100+ GB/s bandwidth, which is 1,000x faster than NVMe on random access, and Linux tmpfs can swap to disk under memory pressure. Compile caches, tempdb, and video scratch space are good fits because the data is throwaway. The catch is volatility: power loss wipes the disk, and the OS page cache often caches the same hot files without the explicit setup.

More Latency scenarios

L1 vs L2 cache
L1 cache is the fastest memory in a computer, typically 1 ns latency (3-5 CPU cycles) and 32-64 KB per core.
View details ➜
L3 cache vs RAM
L3 cache (also called Last Level Cache or LLC) is shared across all cores in a CPU chiplet, typically 16-96 MB, with latency of 10-15 ns.
View details ➜
DDR4 vs DDR5 latency
DDR5 roughly doubles the peak bandwidth of DDR4 (from ~50 GB/s to ~100 GB/s per module), but true latency measured in nanoseconds is nearly unchanged.
View details ➜

Frequently asked questions

When should I use a RAM disk instead of an NVMe SSD?
When the data is disposable and the workload is random-access hungry: compile caches, database temp tables, video rendering scratch, anything that can be regenerated after a reboot. A RAM disk answers at about 80 ns versus NVMe's 100 microseconds, roughly 1,000x faster on random I/O. If losing the contents would upset you, it doesn't belong there.
Doesn't the OS page cache make RAM disks obsolete?
Mostly, yes. Linux and Windows already keep frequently read files in free RAM automatically, so an explicit RAM disk only wins when you need guaranteed residency (no cache eviction) or write-heavy scratch workloads the page cache won't optimize. Modern build systems like Bazel and Buck2 use RAM-backed caches deliberately and are the template for when it's justified.
How do I create a RAM disk on Linux?
Mount a tmpfs: mount -t tmpfs -o size=8G tmpfs /mnt/ramdisk. That's it - no third-party tools needed. tmpfs can spill to swap under memory pressure, which is usually the behavior you want. Windows lacks a native equivalent, so tools like ImDisk fill that role there.