When is a RAM disk worth it over an NVMe SSD?

By TechCompare · Updated · How we check

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.

Calculator

Memory & Storage Throughput Visualizer

Data to transfer: 50 GB

L1 Cache2,000,000 MB/s
Too fast to show
L3 Cache500,000 MB/s
Too fast to show
DDR5 RAM (1 channel)48,000 MB/s
DDR4 RAM (1 channel)25,600 MB/s
NVMe Gen 514,000 MB/s
NVMe Gen 47,000 MB/s
NVMe Gen 33,500 MB/s
SATA SSD550 MB/s
HDD160 MB/s

A RAM disk turns system memory into a block device. Reads go through the operating system's file system, so a small read takes roughly 1.5 µs rather than the 80 ns of a raw memory access, and bandwidth reaches tens of GB/s. An NVMe SSD takes 50-100 µs for a small random read and tops out near 7 GB/s.

For small random reads, a RAM disk is about 50x faster. The trade-off: everything in a RAM disk disappears when the machine loses power or reboots.

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 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

Use a RAM disk for throwaway data like compile caches, tempdb, and video scratch space. Small random reads run about 50x faster than they do on NVMe, and Linux tmpfs can swap to disk under memory pressure. 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 is also called the last level cache, or LLC, because it's the last stop before a request goes out to RAM.
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 a small read in about 1.5 microseconds versus NVMe's 50-100 microseconds, roughly 50x 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.