How does Solid State Drive (SSD) work?

The first commercial HDD was available in 1956 whereas flash memory was invented in the early 1980s and was first commercially available around 1991. This history matters because it is important to note that most of the early storage systems, file systems and database systems research was based on HDD being the primary underlying storage medium. In this blog we will first understand what is a SSD and in the follow up blogs we will explore how the software layers had to adapt to to this new storage medium.

What is a Solid State Drive (SSD)?

It is a non-volatile storage device that is commonly used in modern digital devices to store and retrieve data. It is a non-volatile input/output (IO) device for any computer based system. Most importantly it differs from the HDD in the sense that it is a solid state semiconductor device. Data is stored persistently in transistors. Yes, you are reading that right, persistently in transistors. This technology is popularly know as Flash storage these days and NAND Flash is the most widespread used one. SSDs are designed using this flash memory as storage medium.

Flash Memory

Flash chips are designed to store one or more bits in a single transistor; the level of charge trapped within the transistor is mapped to a binary value. In a single-level cell (SLC) flash, only a single bit is stored within a transistor (i.e., 1 or 0); with a multi-level cell (MLC) flash, two bits are encoded into different levels of charge. There is even triple-level cell (TLC) flash, which encodes 3 bits per cell. Overall, SLC chips achieve higher performance and are more expensive.

How does bit level storage operate?

You should only explore this if you are really interested in understanding the solid state device physics. No harm in skipping and continuing to the next section.
- The basic NAND Flash cell. https://www.cactus-tech.com/resources/blog/details/solid-state-drive-primer-1-the-basic-nand-flash-cell/
- SLC, MLC and TLC NAND Flash. https://www.cactus-tech.com/resources/blog/details/solid-state-drive-primer-2-slc-mlc-and-tlc-nand-flash/

Flash Interface

The flash memory is organized in a very different way as compared to a basic block based interface for HDD.
More details can be found in the following links:
NAND Architecture
NAND Pages and Blocks

Lets look at the basic operations provided by the flash memory:
Read (page, 512 bytes to 8KB): Read a page by specifying page number.
Erase (block, 128KB to few MBs): Before writing to a page within a flash, the nature of the device requires that you first erase the entire block the page lies by setting each bit to 1.
Program/Write (page): Once a block has been erased, the program com-
mand can be used to change some of the 1’s within a page to 0’s

Once a page has been written, the only way to modify its contents is to erase the entire block within which the page resides and then rewrite the data with modification.

Flash Reliability

As we use them as a storage medium, it is important to understand the reliability the dos/don’ts.

Wearout: when a flash block is erased and programmed, it slowly accrues a little bit of extra charge. Over time, as that extra charge builds up, it becomes increasingly difficult to differentiate between a 0 and a 1. At the point where it becomes impossible, the block becomes unusable. The typical lifetime of a block for SLC-based SSD is around 100,000 P/E cycles.

Disturbance: When accessing a particular page within a flash, it is possible that some bits get flipped in neighboring pages.

SSD architecture from raw Flash memory

A Flash based SSD: Logical Block Diagram

For backward compatibility with HDDs, SSDs provide the same storage interface as HDDs. The standard storage interface is a simple block-
based one, where blocks (sectors) of size 512 bytes (or larger) can be read or written, given a block address. The task of the flash-based SSD is to provide that standard block interface atop the raw flash chips inside it. Note that for flash, a page and block means different whereas for an operating system it may mean different.

Flash Translation Layer (FTL)

The essential functionality is to satisfy client reads and writes by turning them into internal flash operations. The FTL takes read and write requests on logical blocks (that comprise the device interface) and turns them into low-level read, erase, and program commands on the underlying physical blocks and physical pages. There are many approaches that have evolved over the years. The hybrid approach of keeping few page level mappings, many block level mappings and some erased pages to keep writing to is the one that is widely used today.

Flash Controller

Garbage Collection

Because the Flash is written by page and erased by block, it is hard to keep the storage usage defragmented. On top of that, in order to maintain wea leveling and minimize read disturbance, SSDs try to balance out and spread new writes through out the flash. This leads to a new problem of periodically reclaiming dead blocks (with no live data) and erasing them. This is a background operation completely managed by the flash controller but may lead to some foreground performance inteference. To reduce GC costs, some manufacturers overprovision the the device by adding extra flash capacity.

Performance

Unlike hard disk drives, flash-based SSDs have no mechanical components, and in fact are in many ways more similar to DRAM, in that they are “random access” devices. The biggest difference in performance, as compared to disk drives, is realized when performing random reads and writes.

Comparison numbers

HDD vs SSD sample performance measurements

Takeaways

- While the SSDs obtain tens or even hundreds of MB/s in random I/Os, this “high performance” hard drive has a peak of just a couple MB/s.
- In terms of sequential performance, there is much less of a difference; while the SSDs perform better, a hard drive is still a good choice if sequential performance is all you need.
- SSD random read performance is not as good as SSD random write performance.

Then why haven’t SSDs completely replaced hard drives as the storage medium of choice?
The answer is cost. SSD costs are 10 times more for per unit of storage.

Summary

These performance and cost differences dictate how large-scale stor-
age systems are built. If performance is the main concern, SSDs are a
terrific choice, particularly if random read performance is important. If,
on the other hand, you are assembling a large data center and wish to
store massive amounts of information, the large cost difference will drive you towards hard drives. Of course hybrid approach makes more sense for a sophisticated storage system.

References

- https://www.cactus-tech.com/resources/blog/details/solid-state-drives-101/
- https://pages.cs.wisc.edu/~remzi/OSTEP/file-ssd.pdf
- https://pages.cs.wisc.edu/~jhe/eurosys17-he.pdf