Articles – Understanding RAID

Understanding RAID

RAID – Redundant Array of Inexpensive or Independent Disks.

I couldn’t find much info on RAID so I thought why not key in something I had learned to share with people who wants to RAID their HDD.

The Need for Disk Arrays

Sooner or later a disk drive on the network will fail. Once this is acknowledged, the real problem must be addressed ?how to effectively and economically protect the network and the business from the damaging effects of a failure. The most obvious concern with the disk failure is the loss or corruption of information critical to the enterprise. Such a failure can result in lost productivity, revenue and user or customer satisfaction. Back-up systems offer limited insurance in this area, but they cannot protect data created since the last back-up. The second concern is loss of access to information stored on the network, even when data is not lost. Inaccessibility of data can occur during the repair and restoration process, even in fault-tolerant systems, while the system, or at least its storage components, are shut down to effect repairs. Like loss of data, loss of access can result in loss of productivity and user satisfaction. This can occur even in otherwise fault-tolerant systems, including RAID solutions if they are not designed properly.

The third concern is achieving and maintaining a high level of system performance and responsiveness to support the changing needs of users on network-based servers and application servers. This includes allowing for growth in storage capacity and performance as more users are added to the network and ever more data intensive applications are brought on-line. It also implies that, whenever possible, performance must be maintained in spite of system component failure.

Q: What is RAID? Why would I ever use it?

A: RAID is a way of combining multiple disk drives into a single entity to improve performance and/or reliability. There are a variety of different types and implementations of RAID, each with its own advantages and disadvantages. For example, by putting a copy of the same data on two disks (called disk mirroring, or RAID level 1), read performance can be improved by reading alternately from each disk in the mirror. On average, each disk is less busy, as it is handling only 1/2 the reads (for two disks), or 1/3 (for three disks), etc. In addition, a mirror can improve reliability: if one disk fails, the other disk(s) have a copy of the data. Different ways of combining the disks into one, referred to as RAID levels, can provide greater storage efficiency than simple mirroring, or can alter latency (access-time) performance, or throughput (transfer rate) performance, for reading or writing, while still retaining redundancy that is useful for guarding against failures.

Although RAID can protect against disk failure, it does not protect against operator and administrator (human) error, or against loss due to programming bugs (possibly due to bugs in the RAID software itself). The net abounds with tragic tales of system administrators who have bungled a RAID installation, and have lost all of their data. RAID is not a substitute for frequent, regularly scheduled backup.

RAID can be implemented in hardware, in the form of special disk controllers, or in software, as a kernel module that is layered in between the low-level disk driver, and the file system which sits above it. RAID hardware is always a “disk controller”, that is, a device to which one can cable up the disk drives. Usually it comes in the form of an adapter card that will plug into a ISA/EISA/PCI/S-Bus/MicroChannel slot. However, some RAID controllers are in the form of a box that connects into the cable in between the usual system disk controller, and the disk drives. Small ones may fit into a drive bay; large ones may be built into a storage cabinet with its own drive bays and power supply. The latest RAID hardware used with the latest & fastest CPU will usually provide the best overall performance, although at a significant price. This is because most RAID controllers come with on-board DSP’s and memory cache that can off-load a considerable amount of processing from the main CPU, as well as allow high transfer rates into the large controller cache. Old RAID hardware can act as a “de-accelerator” when used with newer CPU’s: yesterday’s fancy DSP and cache can act as a bottleneck, and it’s performance is often beaten by pure-software RAID and new but otherwise plain, run-of-the-mill disk controllers. RAID hardware can offer an advantage over pure-software RAID, if it can makes use of disk-spindle synchronization and its knowledge of the disk-platter position with regard to the disk head, and the desired disk-block.

Q: What are RAID levels? Why so many? What distinguishes them?

A: The different RAID levels have different performance, redundancy, storage capacity, reliability and cost characteristics. Most, but not all levels of RAID offer redundancy against disk failure. Of those that offer redundancy, RAID-1 and RAID-5 are the most popular. RAID-1 offers better performance, while RAID-5 provides for more efficient use of the available storage space. However, tuning for performance is an entirely different matter, as performance depends strongly on a large variety of factors, from the type of application, to the sizes of stripes, blocks, and files.

RAID-0 or Striping is the underlying concept behind all of the other RAID levels. A stripe is a contiguous sequence of disk blocks. Striped disks. Highest performance, but no redundancy, and therefore really isn’t RAID at all. Very seldom used because of the reduced reliability: if one drive fails, the entire array fails. However, it is the concept of striping that is important to understand: rather than writing a data to sequential blocks on one drive, each subsequent block is written to the next physical drive. This gives great read performance because multiple drives work on getting their portion of the data, thus delivering it back to the computer much faster than one drive alone could. To the OS and to the user, a striped RAID drive looks like ONE larger drive. Indeed, in hardware RAID implementations, you wouldn’t know at all that this was not just one big disk without special software provided by the RAID manufacturer. Note that there is nothing special about the disk drives themselves: it is the disk controller that provides the abstraction that makes the striped drives look like one drive.

RAID-1 is also referred to as “mirroring”. Two (or more) partitions, all of the same size, each store an exact copy of all data, disk-block by disk-block. Mirroring gives strong protection against disk failure: if one disk fails, there is another with the an exact copy of the same data. Mirroring can also help improve performance in I/O-laden systems, as read requests can be divided up between several disks. Unfortunately, mirroring is also the least efficient in terms of storage: two mirrored partitions can store no more data than a single partition.

This mirroring can be combined with RAID 0, giving striped disks that are mirrored. Although this offers the high performance of RAID 0 and redundancy, it is much more expensive and typically not seen except in environments where cost just doesn’t matter.

RAID-2 and RAID-3 are seldom used anymore, and to some degree are have been made obsolete by modern disk technology. RAID-2 is similar to RAID-4, but stores ECC information instead of parity. Since all modern disk drives incorporate ECC under the covers, this offers little additional protection. RAID-2 can offer greater data consistency if power is lost during a write; however, battery backup and a clean shutdown can offer the same benefits. RAID-3 is similar to RAID-4, except that it uses the smallest possible stripe size. As a result, any given read will involve all disks, making overlapping I/O requests difficult/impossible. In order to avoid delay due to rotational latency, RAID-3 requires that all disk drive spindles be synchronized. Most modern disk drives lack spindle-synchronization ability, or, if capable of it, lack the needed connectors, cables, and manufacturer documentation.

RAID-4 interleaves stripes like RAID-0, but it requires an additional partition to store parity information. The parity is used to offer redundancy: if any one of the disks fail, the data on the remaining disks can be used to reconstruct the data that was on the failed disk. Given N data disks, and one parity disk, the parity stripe is computed by taking one stripe from each of the data disks, and XOR’ing them together. Thus, the storage capacity of a an (N+1)-disk RAID-4 array is N, which is a lot better than mirroring (N+1) drives, and is almost as good as a RAID-0 setup for large N. Note that for N=1, where there is one data drive, and one parity drive, RAID-4 is a lot like mirroring, in that each of the two disks is a copy of each other. However, RAID-4 does NOT offer the read-performance of mirroring, and offers considerably degraded write performance. In brief, this is because updating the parity requires a read of the old parity, before the new parity can be calculated and written out. In an environment with lots of writes, the parity disk can become a bottleneck, as each write must access the parity disk.

RAID-5 avoids the write-bottleneck of RAID-4 by alternately storing the parity stripe on each of the drives. However, write performance is still not as good as for mirroring, as the parity stripe must still be read and XOR’ed before it is written. Read performance is also not as good as it is for mirroring, as, after all, there is only one copy of the data, not two or more. RAID-5’s principle advantage over mirroring is that it offers redundancy and protection against single-drive failure, while offering far more storage capacity when used with three or more drives.

RAID 0 + 1 or commonly known as RAID-10, basically involves stripping 2 different disk arrays of similar size then followed by the mirroring of these 2 disk arrays.

There are also other levels of RAID, such as 50, 100, etc, mostly involving RAID 5 and then mirroring or stripping them.

Why use RAID 5?

This is a popular configuration offering excellent read performance and high reliability. The concept here is to have parity data, but to spread it over all the drives. This lets writes overlap because typical small writes access one data drive and one parity drive. If another write is accessing a different set of drives, the two writes can be done in parallel, which is not possible with a dedicated parity drive as described above. This requires a minimum of 3 disk drives, and more is better. RAID 5 is less expensive than mirroring (for equivalent storage), can provide very fast reads, particularly with more than 3 drives, and can survive a single drive failure. The disadvantage is that write performance is not as good (but most applications do much more reading than writing) and that in the event of failure, both read and write performance suffer due to the overhead involved in reconstructing data from parity information.

Recently, non-official designations such as RAID 6 have been offered at the very high end of the market. These are really just RAID 5 implementations but with multiple parity writes, so that the array can withstand the failure of multiple drives simultaneously. Obviously only very high end systems need such redundancy.

The concept of parity utilizes the mathematical properties of the XOR (Exclusive OR). For example, if you XOR the values 12 and 15, you’ll get 3. If you XOR 3 (the result of your first XOR) with either 12 or 15, you’ll get the other value. That “3” would be the parity information that would be used to reconstruct the “12” or the “15” if each of those represented data stored on a different disk. The XOR is a very quick operation, handled directly by the CPU. but of course it does involve some overhead, so writing involves both an extra calculation (the XOR) and another disk write (the disk write is concurrent with the other writes though, so that really doesn’t hurt anything).

If a drive fails, the controller provides the “missing” data by calculating it from the data it does have: the other data drive(s) and the parity drive. This is, of course, slower than reading it from the disk would be.

In other word when a drive in RAID 5 fails, the other drives will continue to work but at a slower pace since they need to compensate for the lost of 1 drive and calculating the data lost using the parity in left in the rest of the drives. Using a hardware based RAID 5 controller will be more efficient than software RAID, since it will built the data without overloading and minimising data bottlenecks from the system CPU.

Highly recommended!

– Contributed by Nick aka The Zard
19 Dec 2004

Pages

Sidebar Block

* Function Not Configured *

Archives