SSD vs RAM: what's the cost/durability difference and limitation to using SSD as memory?

It all boils down to latency.

DDR4 latencies are measured in nanoseconds. It's typically somewhere under 20ns.

SSD latencies are measured in microseconds. The fastest SSDs are in the region of 25μs.

1μs = 1000ns. Your fastest SSD has a latency 1000x longer than DDR4.

Even more telling is that RAM is actually too slow, so there's L1 and L2 cache on top. Every time you hit DRAM, you're wasting about 100 cycles waiting for the data fetch — so on-CPU cache is used to reduce that to <10 cycles for frequently-accessed data. Imagine waiting 100,000 cycles instead...


Another, related, factor is random access times. You quote 4GB/s — that's sequential speeds. With random read, you see something more like 50MB/s, while random write might top out at 150MB/s. And RAM is read a lot more than it is written.

Compared to DRAM, SSDs are optimised for high throughput, not a high number of operations per second. As another example, erase blocks on SSDs are quite big, which means rewriting many small chunks is expensive.


There are technologies that bridge the gap. 3D XPoint, branded Optane by Intel, is faster than NAND (SSDs) and cheaper than DRAM.


SSD vs RAM: what's the cost/durability difference and limitation to using SSD as memory?

The cost, durability, and performance, e.g. latency, comparisons are actually irrelevant because you simply cannot use a SSD as (main) memory or RAM. One important distinction is that RAM is byte and/or word addressable. Mass storage devices such as SSD or HDD are block devices that are only sector addressable.

You cannot read or write just one byte or word from/to a block device. In order to perform a read or write operation from/to a block device, an entire (physical) block (aka sector) has to be read or written. You need RAM to buffer the block between the CPU and the mass storage device.

Bottom line: you cannot simply replace RAM with a block device.

If you try to expand the existing amount of RAM used for main memory by copying code and data to/from a SSD/HDD, then you're essentially using virtual memory (and you'll need a Memory Management Unit).


ADDENDUM

Comparing the performance (e.g. latency, throughput, et cetera) between RAM technology versus SSD technology to answer the question about "why SSDs can't be used as RAM" is misguided because it's irrelevant. A mass-storage block device is incompatible as a substitute for RAM as main memory.

IMO it's like asking "how much pizza do I have to eat to stay hydrated?", and answers cite the water content of different pizza toppings. But the correct and simple answer is that pizza is not a replacement for drinking water.

Likewise a SSD (with its block interface) is not a replacement for RAM in a computer. In other words, the correct answer is based on computer architecture concepts rather than comparing performance numbers.


what makes RAM cells so fast and durable vs NAND cells,

You're trying to compare apples to oranges.

RAM (Random Access Memory) is a functional classification of memory. The acronym does not specify a technology, i.e. RAM for main memory is typically a type of SDRAM in a modern PC. Older computers used ferrite cores for RAM.

For economic reasons it's common that faster speed means less capacity and slower speeds mean more capacity. Your average computer will have SDRAM for main memory (usually shortened to just RAM) and SRAM for CPU caches. SRAM is really expensive in comparison to SDRAM but also much faster. See Why is SRAM faster than DRAM? for information as to why SRAM is faster than SDRAM. There are also exceptions to this for embedded devices or other kinds of computers like the Cray X-MP.

NAND is technology for flash memory. Note that NAND flash (at the chip level) typically has to be accessed as a block device.

why (...) does RAM cost more per GB than SSD?

Same apples to oranges comparison. Supply versus demand (which is driven by performance) has a huge influence on pricing. In addition the manufacturing processes are different which also has an impact. You can't just use your SDRAM chips and put them in an SSD and call it a day.


for example a RAM disk (though volatile).

RAM is the acronym for Random Access Memory. There is no assumption or characterization about volatility. In fact, if you're old enough to remember, computers (but not PCs) up to the 1980s used (non-volatile) ferrite core memory. Battery-backed static RAM is another way to implement (main) memory that is non-volatile. Some devices like RAID cards actually need such mechanisms even today.

It's the (now prevalent) use of (synchronous) dynamic RAM for main memory and its attribute of volatility that leads to the (common but) faulty association of RAM and volatility.

  • RAM is (commonly) implemented by (synchronous) dynamic RAM.
  • (S)DRAM is volatile.
  • Therefore RAM is volatile. Improper (if not faulty) syllogism!