· hardware

What is SSD Write Amplification and How It Leads to Disk Failure

Types of SSDs

Solid State Devices (SSD) are different from HDDs that they store data as electronic voltage on NAND cells rather than on magnetic mediums. SSDs can be broadly classified into three (1) SLC - Single Level Cell (2) MLC - Multi Level Cell (3) TLC - Tripple Level Cell. SLCs store one bit of data per NAND cell. Usually their capacity will be less and more expensive but they will be more durable. MLCs store two bits per cell and TLCs store three bits per cell. So MLCs and TLCs have more capacity per inch than SLC and usually will be cheaper. MLCs and TLCs store multiple bits on the same cell using different voltages. In an SSD, these cells are usually grouped together in to pages. Usually the page size will be 4K. Pages are again grouped together into Blocks. The usual block size is 512K (126 pages x 4K)

What is Write Amplification?

One of the unique property of SSD is that it can read and write data at page level for empty pages. But erase or rewrite data can be done only at Block level. To rewrite data on a page (even a single bit), the whole block will need to be rewritten. (ie, to rewrite a 4KB page, 512KB block has to be rewritten). First, the whole block will be copied in to the memory, then replace only the data in the page and finally copy the whole block from memory to NAND. In short, just to rewrite a 4KB page, an entire block of 512KB has to be written and trasferred to and back from memeory. This is called write amplification.

Since this rewrite (or reusing deleted pages) is expensive, SSD controllers will not rewrite deleted pages, but just mark those pages as invalid and keep writing to the empty pages of SSD. But as the SSD becomes full, it will have to reuse those deleted pages. From that moment onwards the performance of SSDs will degrade exponentially.

The two side effects of write amplification are latency and disk failure.

How do SSDs deal with Latency due to Write Amplification?

To remediate this problem, SSDs incorporate a DRAM and a small processor inside the SSD itself. The DRAM module will act as a write behind cache. ie, the data will be written to DRAM and a success response send back to Host OS. Then the processor in the SSD takes the data from DRAM and write it to NAND cells.

How do SSDs fail due to Write Amplification?

In an SSD each NAND cell has a finite life span. While the cells can withstand a huge number of reads, it can withstand only a few number of P/E (Program/Erase) cycles. P/E cycle is the block rewrite process described above. The write amplification will lead to a lot more P/E cycles, will cause NAND cells to fail and it will ultimately lead to whole SSD failure.

Conclusion

Have an SSD? Use it only for read and append data. Keep the deletes and rewrites to the minimum to extend the life of your SSD. On an enterprise level, SSDs are suitable for log appending datastores like Cassandra. If you have a database which has huge number of update/delete operations, expect SSD failures.