Historically, disk storage has always been less expensive (on a per gigabyte basis) than RAM. In addition, systems can generally accommodate far more disk space than RAM. For example, the computer I am using right now has 128 GB of RAM, which is the maximum amount that the system board will accommodate. It also has 2 TB of disk space, which is not even close to the PC’s limit. Given the cost of RAM and its capacity limitations, a variety of solutions have been introduced that allow disk space to be used to make up for RAM shortages. However, the opposite has also been done.
A RAM disk is a virtual disk that exists entirely within a system’s RAM. The main advantage to using a RAM disk is that they are extremely fast, especially when compared to HDDs. However, there are at least two disadvantages to RAM. First, RAM disks are volatile. If the computer loses power, then anything stored in the RAM disk is lost unless it is protected by battery. The other disadvantage is that any RAM that is allocated to a RAM disk is not available for use as system RAM.
These disadvantages, along with RAM costs, have usually meant that RAM disks were used only in very specific situations. For example, when I have needed to create many virtual machines, I have occasionally copied an operating system ISO file to a RAM disk as a way of speeding up the provisioning process.
The real question, however, is whether RAM disks are still relevant in today’s world. After all, NVMe storage can perform at speeds that rival those of RAM disks, so do RAM disks still have any practical use cases?
The first thing to consider is that the performance of both NVMe and RAM disks can vary widely. A RAM disk based on DDR4 (3200) memory, for example, has a peak transfer rate of 25.6 GB/s. As impressive as this may be, this transfer rate is often regarded as theoretical because the CPU configuration, the system board and the workload play heavily into the actual transfer speeds that can be achieved.
Similarly, an NVMe disk that is based on the PCIe 4.0 standard and that uses all 16 PCIe lanes can theoretically achieve speeds of up to 32 GB/s. Again, though, the actual speeds that can be achieved can vary considerably based on the hardware configuration and workload. Many of the NVMe drives available today are based on the older PCIe 3.0 standard, and even a PCIe 4.0 drive might use only four lanes. All of this is to say that whether you are using a RAM disk or NVMe, there are numerous factors that will impact your overall performance.
As a way of illustrating the differences that disk types and workloads can make, I used CrystalDiskMark 8.0.4 Standard Edition to benchmark the performance of three different disks: an M.2 SATA disk, an NVMe disk and a RAM disk. Each of these disks was on the same computer, and all tests were based on CrystalDiskMark’s default profile and 4 GB of test data. The RAM disk was 54 GB in size and created using the ImDisk Toolkit.
Figure 1 shows the benchmark numbers for the M.2-based SATA disk. Figure 2 illustrates the benchmark for the NVMe disk, and Figure 3 shows the benchmark for the RAM disk.
This is the performance data for the SATA disk.
This is the performance data for the NVMe disk.
This is the performance data for the RAM disk.
Although these benchmarks are unique to my computer, there are a few things to consider. First, none of the disks returned benchmark numbers that were near their theoretical maximums.
Second, each disk’s performance varied considerably based on the workload type. Random operations were consistently slower than sequential operations, and there were also performance differences between read and write operations.
Third, the NVMe and SATA disks were not empty at the time of the tests. SSDs tend to become slower as they are used, so that likely played a factor in the benchmark numbers. Even so, both disks were relatively new, and the NVMe disk contained a relatively small amount of data.
So, do RAM disks have a place in today’s world? In certain circumstances, RAM disks can indeed outperform NVMe disks to a significant degree. As such, they can be well suited to certain types of workloads. One of the best use cases for RAM disks could be hosting container workloads because containerized workloads tend to be transient in nature and may benefit from a RAM disk’s performance in certain high density configurations.
Even so, media type selections are rarely absolute. It’s always important to choose a media type based on the workload’s I/O characteristics. Likewise the capacity limitations and temporary nature of RAM disks make them more suitable for some workloads than others, regardless of performance.