How does a solid state drive write data?

Solid state drives (SSDs) are a type of non-volatile storage device that uses flash memory to store persistent data. Unlike hard disk drives (HDDs) that rely on spinning platters and mechanical parts, SSDs have no moving components and are inherently more durable and shock resistant. The first SSDs were introduced in the 1970s for military and industrial applications, but didn’t become commercially popular in mainstream computing until the 2000s.

Some key advantages of SSDs over HDDs include faster read/write speeds, lower latency, reduced power consumption, and better physical durability. However, SSDs tend to be more expensive per gigabyte compared to HDDs. SSDs are well-suited for applications that demand high performance like gaming, creative workflows, and enterprise databases. Consumer SSDs connect via SATA, PCIe, and NVMe interfaces. As manufacturing processes continue to improve, SSD prices keep falling while capacities increase.

SSD Architecture

SSDs contain several key internal components that work together to store and retrieve data quickly. The main components involved are:

Controller

The controller is the brain of the SSD. It manages all read and write operations and ensures data integrity. The controller maximizes performance through techniques like parallelism and interleaving Samsung.

NAND Flash Memory

NAND flash memory provides the non-volatile storage capacity of the SSD. It retains data when power is removed. Data is stored in an array of NAND flash memory chips StorageReview.

DRAM Cache

The DRAM cache provides high-speed temporary data storage to boost performance. Frequently accessed data is cached in DRAM for faster access StorageReview.

Host Interface

The host interface connects the SSD to the computer system. Common interfaces include SATA, PCIe, and NVMe. The interface affects transfer speeds StorageReview.

Writing Data

SSDs write data in pages, which are typically 8KB in size. When new data needs to be written, the SSD controller identifies an empty page to write to through a process called page programming. The controller writes the data to the page byte by byte, verifying each byte is written correctly through an error checking process.

To maximize performance and ensure even wear on the NAND flash memory cells, SSD controllers utilize a process called wear leveling. This involves writing data across all available pages in the SSD evenly. It prevents any single cell from wearing out prematurely.

SSD controllers also perform garbage collection, which consolidates data from partially filled pages to completely fill other pages. This frees up empty pages for new writes. Garbage collection runs in the background when the drive is idle.

Together, wear leveling and garbage collection enable SSDs to write data quickly and efficiently. By leveraging empty pages across the entire drive, SSDs can sustain high write performance over their lifespan. (Sources: TechTarget, Data Recovery Specialists)

Erasing Data

SSDs need to erase data before they can write new data to those NAND flash storage cells. However, NAND flash memory can’t simply overwrite existing data like a traditional hard disk drive. Instead, SSDs need to use a process called block erasure. This involves applying a high voltage to an entire block of cells in order to reset them to a blank state (prior to writing).

Block sizes vary across SSD models but are commonly around 256 KB to 2 MB in size. The SSD controller erases full blocks, even if only part of the block contains invalid or stale data. This introduces write amplification – where more data needs to be rewritten than was originally requested.

Operating systems can optimize this process using the TRIM command. This allows the OS to notify the SSD which blocks contain invalid/stale data that can be erased and prepared for reuse. The SSD will then perform garbage collection in the background to erase and consolidate these blocks. Enabling TRIM helps reduce write amplification and improves overall efficiency and performance.

According to Architecture and Design of the Linux Storage Stack, block erasure is a key difference between SSDs and HDDs that introduces write amplification and other characteristics SSDs need to account for.

Read Disturb Errors

Read disturb errors occur when reading data from one location in an SSD causes the voltage threshold of cells in nearby locations to shift, leading to bit errors. This is a result of electric field coupling between adjacent cells in modern high-density NAND flash memory. Over time, repeatedly reading the same data causes more and more bit errors (Li et al.).

To mitigate read disturb errors, manufacturers have implemented read scrubbing/refreshing techniques. The SSD controller proactively reads data in the background and rewrites it to refresh the cells. However, this can lead to increased write amplification. More advanced mitigation techniques selectively refresh data based on the observed error rate and read frequency to optimize refresh operations (Li et al.). The scheduling of read operations can also help, by minimizing repeated reads to the same location.

Write Amplification

Write amplification is an undesirable phenomenon associated with flash memory and solid state drives (SSDs), where the actual amount of information physically written to the storage media is a multiple of the logical amount intended to be written. This occurs due to the way SSDs handle erasures and rewrites of data (What is write amplification factor (WAF)? Definition from …).

Write amplification occurs due to the need to erase blocks before new data can be written, coupled with the fact that erasures can only happen at the block level, not the page level. So if even a single page in a block needs to be overwritten, the entire block has to be erased and rewritten. This amplifies the amount of actual writes to physical media compared to the logical writes from the host system. The Write Amplification Factor (WAF) is used as a measure of this amplification.

Mitigating write amplification requires optimizing how data is written at the software and hardware levels. At the hardware level, SSDs with larger block sizes suffer less from write amplification. At the software level, the filesystem and I/O scheduler can optimize write order and utilize the TRIM command to inform the SSD which blocks can be deleted (Using SSD data placement to lessen SSD write amplification). Aligning writes to the internal page boundaries also helps.

Write Endurance

One key metric for SSD endurance is P/E cycles. This refers to the number of times each cell in the SSD can be programmed and erased before it can no longer reliably store data. The lower the P/E cycle rating, the shorter the usable lifespan of the SSD.

Typical P/E cycle ratings range from 1,000 to 100,000 writes per cell. However, the actual endurance depends on several factors:

  • NAND flash technology – SLC has the highest endurance, while QLC has the lowest.
  • Over-provisioning – Having spare capacity allows the drive to spread writes across more cells.
  • Wear leveling algorithms – This ensures all cells are worn evenly so no single cell fails prematurely.
  • Workload – Drives in read-heavy use will last longer than write-intensive applications.

Endurance has improved dramatically over the years through advanced NAND flash and controller innovations. However, P/E cycle ratings still provide a basic measure for comparing SSD lifespan across different models and use cases.

Source: https://www.reddit.com/r/buildapc/comments/et0y9q/confused_about_ssd_endurance_pe_cycles_vs_tbw/

Data Integrity

Data integrity of the information stored on solid state drives is critical for stable and reliable operation. Two main technologies to ensure data integrity are error correcting codes (ECC) and RAID.

ECC works by calculating extra parity bits and storing them alongside the data. The ECC logic can detect and recover from common errors like bit flips. The strength of ECC varies based on the algorithm, with more advanced schemes able to correct more bit errors [1]. Some SSDs use LDPC (low density parity check) codes that can handle hundreds of bit errors.

RAID (redundant array of independent disks) offers another layer of protection against data loss. RAID replicates or spreads data across multiple SSD drives. If a drive fails, the data can be reconstructed from the other drives. Some common RAID levels are RAID 0, RAID 1, and RAID 5. RAID improves integrity but lowers usable capacity. Companies like Facebook use RAID across flash storage to ensure reliability [2].

Security

One important aspect of SSD storage is ensuring the security of users’ data. SSDs offer features like encryption and secure erase to prevent unauthorized access to sensitive information. SSD encryption involves encoding data stored on the drive so that it can only be accessed with a decryption key (KIOXIA). This protects data from being exploited if the drive is lost, stolen, or compromised in some way. The specific encryption algorithms may vary between SSD models and manufacturers. Samsung SSDs, for example, support AES-XTS 256-bit hardware encryption to safeguard data (Samsung).

Another security capability of SSDs is the ability to securely erase data from the drive. When deleting files normally, the references to those files are removed but the underlying data may still exist on the storage media. With SSDs, a secure erase can be performed to actively overwrite all data with meaningless information. This prevents forensic recovery of any remnants of sensitive information. Secure erase functionality ensures SSDs can be safely repurposed or disposed of without compromising confidential user data (KIOXIA).

Conclusion

In summary, solid state drives write data to NAND flash memory cells using various complex processes such as program/erase cycles, wear leveling, and garbage collection. Data is written in pages and blocks, with ECC and encryption utilized for data integrity and security. The performance and reliability of SSDs have improved tremendously over the years thanks to advances like 3D NAND and newer interfaces. However, challenges remain when it comes to endurance and ensuring data retention over long periods.

Looking ahead, emerging technologies like QLC and PLC NAND, Z-NAND, MRAM, ReRAM, and NVDIMMs may shape the future of solid state storage. Continued innovation in controller design, interface protocols, and software will enable SSDs with higher capacities, speeds, endurance and power efficiency. The outlook for SSDs replacing HDDs as the dominant form of computer storage looks promising. As costs continue to decline, SSDs have the potential to fully replace mechanical hard drives in the majority of applications within the next 5-10 years.