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 no built-in RAM disk, so tools such as the third-party ImDisk can fill that role. For databases, putting tempdb or a read replica entirely in RAM can dramatically improve query performance. Bazel and Buck2 normally use filesystem-backed build output and cache paths, although you can point their caches at a RAM-backed filesystem when that trade-off fits your workflow. 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-6000 provides about 1.67x the theoretical bandwidth of DDR4-3600 at the same 64-bit aggregate data width: 48.0 GB/s versus 28.8 GB/s per module or memory channel.
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?
Often, 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. Build systems such as Bazel and Buck2 use filesystem-backed cache paths by default, but you can configure a RAM-backed path for disposable artifacts when testing shows a benefit.
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.