Tuesday, 28 January 2014

RAID storage

RAID was originally defined as Redundant Array of Inexpensive Drives, but RAID setups were traditionally very expensive so the definition of "I" became Independent. The costs have recently come down significantly because of commoditization and RAID features are now embedded on to most higher-end motherboards. Storage RAIDs were primarily designed to improve fault tolerance, offer better performance, and easier storage management because it presents multiple hard drives as a single storage volume which simplifies storage management. Before we start talking about the different RAID types, I'm going to define some basic concepts first.
Fault tolerance defined: Basic fault tolerance in the world of storage means your data is intact even if one or more hard drives fails. Some of the more expensive RAID types permit multiple hard drive failures without loss of data. There are also more advanced forms of fault tolerance in the enterprise storage world called path redundancy (AKA multi-path) which allows different storage controllers and the connectors that connect hard drives to fail without loss in service. Path redundancy isn't considered a RAID technology but it is a form of storage fault tolerance.
Storage performance defined: There are two basic metrics of performance in the world of storage. They are I/O performance and throughput. In general, read performance is more valued than write performance because storage devices spend the majority of their time reading data. I/O (Input/Output) performance is the measure of how many small random read/write requests can be processed in a single second and it is very important in the server world, especially database type applications. IOPS (I/O per second) is the common unit of measurement for I/O performance.
Throughput is the measurement of how much data can be read or written in a single second and it is important in certain server applications and very desirable for home use. Throughput is typically measured in MB/sec (megabytes transferred per second) though mbps (megabits per second) is sometimes also used to describe storage communication speeds. There is sometimes confusion between megabits versus megabytes since they sound alike. For example, 100 megabit FastEthernet might sound faster than a typical hard drive that gets 70 MB/sec but this would be like thinking that 100 ounces weighs more than 70 pounds. In reality, the hard drive is much faster because 70 MB/sec is equivalent to 560 mbps.
RAID techniques defined: There are three fundamental RAID techniques and the various RAID types can use one or more of these techniques. The three fundamental techniques are:


Mirroring: Data mirroring stores the same data across two hard drives which provides redundancy and read speed. It's redundant because if a single drive fails, the other drive still has the data. It's great on read I/O performance and read throughput because it can independently process two read requests at the same time. In a well implemented RAID controller that uses mirroring, the read IOPS and read throughput (for two tasks) can be twice that of a single drive. Write IOPS and write throughput aren't any faster than a single hard drive because they can't be process independently since data must be written to both hard drives at the same time. The downside to mirroring is that your capacity is only half of the total capacity of all your hard drives so it's expensive.
Striping: Data striping distributes data across multiple hard drives. Striping scales very well on read and write throughput for single tasks but it has less read throughput than data mirroring when processing multiple tasks. A good RAID controller can produce single-task read/write throughput equal to the total throughput of each individual drive. Striping also produces better read and write IOPS though it's not as effective on read IOPS as data mirroring. You also get a large consolidated drive volume equal to the total capacity of all the drives in the RAID array. Striping is rarely used by itself because it provides zero fault tolerance and a single drive failure causes not only the data on that drive to fail, but the entire RAID array. Striping is often used in conjunction with data mirroring or with parity.
Striping with parity: Because striping alone is so unreliable in terms of fault tolerance, striping with parity solves the reliability problem at the expense of some capacity and a big hit on write IOPS and write throughput compared to just data striping. Data is striped across multiple hard drives just like normal data striping but a parity is generated and stored on one or more hard drives. Parity data allows a RAID volume to be reconstructed if one (sometimes two) hard drives fail within the array. Generating parity can be done in the RAID controller hardware or done via software (driver level, OS level, or add-on volume manager) using the general purpose processor. The hardware method of generating parity either results in an expensive RAID controller and/or poor throughput performance. The software method is computationally expensive though that's no longer a problem with fast multi-core processors. Despite the performance and capacity penalty of using parity, parity uses up far less capacity than data mirroring while providing drive fault tolerance making this a very cost-effective form of reliable large-capacity storage.

Basic RAID Levels defined

RAID 0: 1 disk normal
RAID 1: 2 disks mirroring N/2
RAID 2,3,4,5: SINGLE PARITY DISK N-1 
RAID 6: DOUBLE PARITY DISK N-2
The various RAID types used in the storage world are defined by Level numbers. At the basic level, we have RAID Level 0 through 6. We also have various composite RAID types comprised of multiple RAID levels. Note that people often drop the word "Level" when referring to RAID types and this has become an accepted practice. Also note that even though same-sized hard drives are not technically required, RAID normally uses hard drives of similar size. Any implementation that uses different sized hard drives will result in wasted capacity.

1 diskos clustering
RAID Level 0: RAID Level 0 is the cluster-level implementation of data striping and it is the only RAID type that doesn't care about fault tolerance. Clusters can vary in size and are user-definable but they are typically blocks of 64 thousand bytes. The clusters are evenly distributed across multiple hard drives. It's used by people who don't care about data integrity if a single drive fails. This RAID type is sometimes used by video editing professionals who are only using the drive as a temporary work space. It's also used by some PC enthusiasts who want maximum throughput and capacity.

2 diskoi mirroring, wasted space performance boost
RAID Level 1: RAID Level 1 is the pure implementation of data mirroring. In a nutshell RAID Level 1 gives you fault tolerance but it cuts your usable capacity in half and it offers excellent throughput and I/O performance. This RAID level is often used in servers for the system partition for enhanced reliability but PC enthusiasts can also get a nice performance boost from RAID Level 1. Using multiple independent RAID Level 1 volumes can offer the best performance for database storage.

e.g 5 drives and 1 for parity storage N-1 IF N=6 then available capacity is 5
RAID Level 2: RAID Level 2 is a bit-level implementation of data striping with parity. The bits are evenly distributed across multiple hard drives and one of the drives in the RAID is designated to store parity. Out of an array with "N" number of drives, the total capacity is equal to the sum of "N-1" hard drives. For example, an array with 6 equal sized hard drives will have the combined capacity of 5 hard drives. It's interesting to note that this RAID level is almost forgotten and is very rarely used.

SAME AS RAID 2 BUT THIS TIME BYTES ARE STORED FOR DATA STRIPPING
RAID Level 3: RAID Level 3 is a byte-level implementation of data striping with parity. The bytes are evenly distributed across multiple hard drives and one of the drives in the RAID is designated to store parity. Out of an array with "N" number of drives, the total capacity is equal to the sum of "N-1" hard drives. For example, an array with 4 equal sized hard drives will have the combined capacity of 3 hard drives. This RAID level is not so commonly used and is rarely supported.

SAME AS RAID 3 BUT THIS TIME CLUSTERS ARE USED TO STORE DATA FOR  STRIPPING
RAID Level 4: RAID Level 4 is a cluster-level implementation of data striping with parity. Clusters can vary in size and are user-definable but they are typically blocks of 64 thousand bytes. The clusters are evenly distributed across multiple hard drives and one of the drives in the RAID is designated to store parity. Out of an array with "N" number of drives, the total capacity is equal to the sum of "N-1" hard drives. For example, an array with 8 equal sized hard drives will have the combined capacity of 7 hard drives. This RAID level is not so commonly used and is rarely supported.
RAID Level 5: RAID Level 5 is a cluster-level implementation of data striping with DISTRIBUTED parity for enhanced performance. Clusters can vary in size and are user-definable but they are typically blocks of 64 thousand bytes. The clusters and parity are evenly distributed across multiple hard drives and this provides better performance than using a single drive for parity. Out of an array with "N" number of drives, the total capacity is equal to the sum of "N-1" hard drives. For example, an array with 7 equal sized hard drives will have the combined capacity of 6 hard drives. This is the most common implementation of data striping with parity.

RAID 0: 1 disk normal
RAID 1: 2 disks mirroring N/2
RAID 2,3,4,5: SINGLE PARITY DISK N-1
RAID 6: DOUBLE PARITY DISK N-2
RAID Level 6: RAID Level 6 is a cluster-level implementation of data striping with DUAL distributed parity for enhanced fault tolerance. It's very similar to RAID Level 5 but it uses the equivalent capacity of two hard drives to store parity. RAID Level 6 is used in high-end RAID systems but it's slowly becoming more common as technology becomes more commoditized. Dual parity allows ANY two hard drives in the array to fail without data loss which is unique in all the basic RAID types. If a drive fails in a RAID Level 5 array, you better hope there is a hot spare that will quickly restore the array to a healthy state in a few hours and you don't get a second failure during that recovery time. RAID Level 6 allows that second drive failure during recovery and is considered the ultimate RAID Level for fault tolerance. Out of an array with "N" number of drives, the total capacity is equal to the sum of "N-2" hard drives. For example, an array with 8 equal sized hard drives will have the combined capacity of 6 hard drives.
RAID Level 10 (composite of 1 and 0): RAID Level 10 (sometimes called 1+0) is probably the most common composite RAID type used on the market both in the server and home/enthusiast market. For example, there are plenty of cheap consumer-grade RAID controllers that might support RAID Level 0, 1, and 10 that don't support Level 5. The most common and recommended implementation of mirroring and striping is that mirroring is done before striping. This provides better fault tolerance because it can statistically survive more often with multiple drive failures and performance isn't degraded as much when a single drive has failed in the array. RAID Level 0+1 which does striping before mirroring is considered an inferior form of RAID and is not recommended. RAID Level 10 is very commonly used in database applications because it provides good I/O performance when the application can't distribute its own data across multiple storage volumes. But when the application knows how to evenly distribute data across multiple volumes,independent pairs of RAID Level 1 provides superior performance.