How Solid-State Drives Compare to Standard Hard Drives
Solid-state drives (SSDs) have several advantages and at least one disadvantage compared to hard disk drives (HDD). The advantages of SSDs include high mechanical reliability (because of no moving parts), no noise, and small physical size (they can be as small as a single chip). All of these advantages make the solid-state drive an ideal choice for cRIO and other NI products.
However, solid-state drives have a limited number of write/erase cycles. This disadvantage is the primary focus of this white paper. The physical cells of SSDs wear out over time. For single-level cells (SLCs), the number of write/erase cycles is around 100,000 per cell. For multi-level cells (MLCs), the number of write/erase cycles is around 1,000 to 10,000 per cell. In order to explain how this can affect your application, we will discuss SSD block size, wear leveling, and minimum write sizes from the file system.
Solid-State Drive Blocks
Solid-state drives are physically divided into blocks. Each block represents the minimum unit that can be erased or written on the disk. At the time of this writing, SSD block sizes for cRIO controllers range from 16 KB to 1 MB depending on the size of the SSD, with larger drives having larger block sizes. Unlike HDDs, the blocks on an SSD must be erased before they can be rewritten to. The SSD tries to minimize erases when possible. Because each block can sustain a limited number of write/erase cycles, the drive spreads out the data being written using wear leveling.
Wear leveling uses an algorithm to distribute data writes and erasures evenly across the blocks and extend the life of the drive. Solid-state drives separate logical-block addresses from physical-block addresses. Logical-block addresses are addresses that the file system uses to keep track of where data is. Physical-block addresses represent the actual locations on the SSD where the data is stored. Wear leveling algorithms translate logical-block addresses to physical-block addresses. There are two types of wear leveling algorithms: dynamic wear leveling and static wear leveling. Most modern drives use both, but older drives may use only dynamic wear leveling.
Dynamic wear leveling works by keeping track of the number of write/erase cycles of each block and writing to the least-used blocks. Dynamic wear leveling leaves static (unchanging) data in place without the option to wear-level the blocks the static data is stored on.
Static wear leveling automatically moves static data around on the drive, making more blocks available for dynamic wear leveling. This extends the life of the drive because if, for example, one-fourth of the drive is used for static operating system files, dynamic wear leveling can use only the other three-fourths of the drive, limiting the drive to three-fourths of its life span.
Wear leveling is less effective with fuller drives. More data on the drive increases the number of write/erase cycles, making wear leveling less effective. Therefore, we recommend that you limit the data on an SSD to 80% of capacity.
In general, higher-capacity SSDs have longer life spans. Wear leveling distributes wear evenly across the SSD, and higher-capacity SSDs have more blocks to write to, so each block is written and erased much less frequently. The life span expectancy of a drive is approximately linear with its size. For example, doubling the size of the SSD will double the life span of the drive for a similar use case.
File System Used on NI LabVIEW Real-Time Controllers
Newer PXI RT controllers and all cRIO controllers except the NI cRIO-9002/9004 use a file system called Reliance. The NI KnowledgeBase article linked here lists the PXI controllers that support the Reliance file system. The Reliance file system eliminates the possibility of data corruption due to unexpected power loss. For more information about how Reliance works and how it compares to traditional file systems, visit the Intro to Reliance on the Datalight Website.
Reliance has a minimum write size for writing data to the SSD. If you try to write a smaller size, it will still write the minimum size. At the time of this writing, most NI hardware uses a minimum write size of 8 KB. (The exceptions are the cRIO-901x and cRIO-902x controllers, which use a minimum write size of 16 KB.) You can maximize the efficiency of the SSD by writing files that are the minimum write size or larger, and ideally in sizes that are multiples of the minimum write size. Limiting writes to exact multiples of the write size greatly improves the drive life. For example, 8 KB of data is 8192 bytes. If you write data in multiples of 8192 bytes, the drive will last much longer than if you write data in 8193-byte chunks.
The file system also adds additional writes to store where files are located. This is an additional hidden overhead that can be minimized by larger writes.
NI recommends that you follow a few guidelines when working with SSDs.
- If storing status updates, keep them to once a minute where possible.
- If logging data, try to keep the write size equal to or greater than the minimum write size and use multiples of the write size where possible.
- Follow the guidelines in this DevZone document for examples and further explanations of how to minimize writes to the solid-state drive.
With the guidelines in this white paper and careful planning, you can design almost any application so that the limited life span of the SSD is not a critical issue.
KB 4JKCTSQ0: How do I Install Reliance on my Real-Time PC or PXI Target?
Developer Zone Tutorial: Best Practices for Target File IO with LabVIEW Real-Time
External link: Intro to Reliance on the Datalight Web site