RAID 101 - Introduction to RAID - RAID 5 - Striping with Distributed Parity

Article Index
RAID 101 - Introduction to RAID
RAID 0 - Striping
RAID 1 - Mirroring
RAID 3 - Striping with Dedicated Parity
RAID 5 - Striping with Distributed Parity
Wrap-Up
All Pages

RAID 5 - Striping with Distributed Parity

RAID 5, or Striping with Distributed Parity, requires at least 2 disks for data and one more to count for the parity information, for a total of 3. Many controllers permit a RAID 5 set to be as many as 16 disks - 15 for data and 1 for parity, although in practice a system designer will limit the number of the disks to 3, 5 or 9.

RAID 5 blends the redundancy of RAID 1 with the performance of RAID 0, and also attempts to solve the write performance problem exhibited with RAID 3. RAID 5 is similar to RAID 3, except that instead of storing all the parity information on one specific disk, the parity is stored equally on each disk in the set.

The choice of 3, 5 or 9 disks is no coincidence - since the stripe size will be a number of Kilobytes (210 bytes), the number of data disks is chosen to divide the stripe evenly, and 1 more is added for the parity information. For some RAID controllers, this can provide a big performance increase.

The RAID 5 set is created using the same amount of space on each disk, and the total size is the same as the size used on each disk, times the number of data disks (N-1 disks). If we had a 250GB disk, a 320GB disk and a 500GB disk, the RAID 5 set would use 250GB on each disk, and the total size for the virtual disk would also be 500GB.

RAID 5 offers data protection just like RAID 3 - at most, RAID 5 is 50% more expensive than RAID 0, but that drops to 11% for a 9 disk set. Furthermore, when reading data, the disk controller reads from all of the disks, which is faster than a single disk, but unlike RAID 3, writes about the same amount to every disk in the array, so is not limited in performance the same way.

Here’s our example data - a simple pattern of 3 ones followed by 3 zeroes for simplicity:

111000111000111000111000

Let’s store that data on our RAID 5 set. Just like RAID 0, we split the data into stripes:

11100011

10001110

00111000

Just like RAID 3, each digit of P is calculated by counting the number of "1" digits in the same place on the data disks. If the number of "1" digits is odd, then we store another 1 on the parity disk to show this. If the number of "1" digits is even, then we store a 0 instead. For the first stripe:

Block 1
Block 2
Block 3
Block 4
Disk 1
1
1
1
0
Disk 2
0
0
1
1
Disk 3 - Parity
1
1
0
1


In practice the disk controller uses an operation called "XOR" for "Exclusive OR", which is a faster way of gathering the same data and calculating the parity - and the result matches the example above.

Now we write the second stripe of data, but this time, the space for the parity block will be located on drive B:

Block 1
Block 2
Block 3
Block 4
Disk 1
1
0
0
0
Disk 2 - Parity 0 1
1
0
Disk 3
1 1
1
0

Finally we write the third stripe of data, but this time, the space for the parity block will be located on drive A:

Block 1
Block 2
Block 3
Block 4
Disk 1 - Parity
1 0
1 1
Disk 2 0 0 1 1
Disk 3
1 0 0 0

The final state of our disks is shown here, with the data in blue and the parity in green:

Disk 1
Disk 2
Disk 3
RAID 5 Disk 1
RAID 5 Disk 2
RAID 5 Disk 3

Let's examine what happens when we lose a disk and we try to read the data:

Disk 1
Disk 2
Disk 3
RAID 5 Disk 1
RAID 5 Disk 2
RAID 5 Disk 3

When we try to read our data, we get the first half back from disk 1, "1110". Then the controller takes that data, compares it to the parity on disk 3, and applies the same process as before:

Block 1
Block 2
Block 3
Block 4
Disk 1 - Data
1 1 1 0
Disk 3 - Parity
1
1 0 1
Disk 2 - Calculated Data
0 0 1 1

Now we read stripe 2, which is missing the parity information - so we have the data already, "10001110". When we read stripe 3, we have the opposite problem - we need to calculate the first part of the data:

Block 1
Block 2
Block 3
Block 4
Disk 1 - Parity 1
0 1 1
Disk 3 - Data 1
0 0 0
Disk 2 - Calculated Data
0 0 1 1

And then we append the last part from Disk 3, "1000". We've successfully read or calculated all the data on the RAID set: "111000111000111000111000"

Now we can see that in a RAID 5 set, if one of the disks fails, the data is safe (or at least, can be recalculated).

Where Does RAID 5 Make Sense

RAID 5 is a very common RAID type, primarily because it presents a very good balance between cost and performance, without the drawback of the single parity disk in a RAID 3 set. It does perform faster for reading data than writing, and there are certain specific cases where it will perform badly, but overall balance is excellent.

RAID 5 is used for file servers, large web servers, mail servers, database servers, data warehouses, and for any data sets which do not require high numbers of small data writes.



Comments (4)
  • doublemint  - homebuilt NAS owner
    I'd also like to know what the recovery process is like, especially if the RAID controller fails. Can a failed RAID controller be replaced with one of a different brand and still recover? As a novice, the RAID BIOS is a bit confusing, some pointers would be helpful. I had a motherboard with RAID fail and assumed I could take one of my RAID 1 drives, plug it into another PC and read it however I couldn’t, why?
  • zaphod  - reply
    Im pretty sure youd need both HDs for that to work... not just one.
  • David Rawling  - Your Mileage Will Vary
    Basically, the answer is no - you need the same model of RAID controller to replace a failed one.

    This applies from the virtually-free Intel RAID controllers on the motherboard to the thousand (and multiple-thousand) dollar add-in cards.

    Each controller has its own way of marking the disks as being part of a RAID set - the disk "signature". One brand might write "RAID1-1" to the first disk and "RAID1-2" to the second. Others might use numbers with the brand (MYRAID-716825).

    I guess it comes back to the same comment I made before. RAID is not backup. It only protects you from disk failure.
  • doublemint  - homebuilt NAS owner
    David,

    While unfortunate there isn't more standardization, I understand why this might be. I can't however understand why this would apply to RAID 1 (mirroring). Why do these drives need to be treated any different than non-RAID drives? Just write the same data two places rather than just one.
Comment
Your Contact Details:
Comment:
[b] [i] [u] [url] [quote] [code] [img]   
Banner