Raid 5



In this section we will discuss raid 5. This is one of the more complicated levels to understand. Setting it up is easy, but understanding it is another thing.

What makes this level so difficult? Let's start by looking at the level in basic terms.

Raid level 5 is very similar to raid 0. The data is striped across all disks. Remember raid level 0 is not redundant. If you lose a disk, you lose your data. With raid level 5, things are a little different.

This level uses a concept called, distributed parity, to protect against a disk failure. If you lose any disk in a raid level 5 configuration, the surviving disks can continue to operate because of the parity. In raid 5 the the parity is distributed across all disks in the raid group.

You need at least 3 disks to create a raid 5 configuration.

Below is an illustration of how it works.

Raid 5 - distributed parity
Raid 5

What is parity?Let's look at parity and how it works. Parity is calculated by using the bits of known data. Let's use an example. I will use even parity to illustrate the calculation.

Let's say you have 5 disks in the raid group. I will use a combination of ones and zero to explain this. Look at the table below. This table represents bits on each disk. Disk5 will contain the parity. This table show the data before parity is calculated.

Disk1Disk2Disk3Disk4Disk5
0010Parity

If we use even parity then we will look at the 1's. In the above table, we have only one bit that's on, or is 1. The others are all 0.

So what is needed to make that one bit even? Yep, another one bit. So the parity in this case would be 1.

Let's add the parity bit to disk5.

Disk1Disk2Disk3Disk4Disk5
0010parity bit 1

Hmm, what does this do. Remember, raid 5 is there to protect against a disk failure. Let's say disk2 fails.

Below is the table again with disk2's parity removed.

Disk1Disk2Disk3Disk4Disk5
0disk failed10parity bit 1

Even parity works by checking the 1's and to see if they are even. Let's check the remaining disks data to see what we have. We have two 1's and the rest is 0's.

So the 1's are already even. Al that's needed now is to replace the failed disks bit with a 0. Remember, we already have even 1's, so if we put another 1 in disk2's place, we would have odd parity. If we replace disk2 the raid software will look at the number of 1's and see that it's already even. It will then go ahead and write a 0 when we replace the disk, thereby reconstructing the disk with the information of the other disks.

Disk1Disk2Disk3Disk4Disk5
0write 010parity bit 1

Very clever. Let's look at another example.

Lets make it more interesting. Let's write two stripes to the disks and distribute the parity.

Disk1Disk2Disk3Disk4Disk5
0010parity bit 1
101parity 00

So now we have written 2 stripes and the parity for the first stripe is on disk5, and the parity for stripe 2 is on disk 4.

The reason why Raid 5 distributes parity is performance. There is also a raid level 4, that uses a dedicated parity disk. The problem with this is that your writes are hampered by the speed of this disk. With raid 4 your dedicated parity disk can become the bottleneck.

Raid 4 can only be done with hardware raid. A company called NetApp uses raid 4 in their configurations.

With distributed parity, this doesn't matter as writes of parity is cycled through all the disks. No single disk can become the bottleneck. It can also be configured with software raid.

This time we will fail disk3.

Look at the table now.

Disk1Disk2Disk3Disk4Disk5
00disk failed0parity bit 1
10Disk failedparity 00

Looking at the remaining data, what bits are needed to reconstruct the stripe?

Let's look at the first stripe. There is only a single 1. To make it even we need another 1. The same for the second stripe. So the raid software will calculate this and return the data based on these calculations.

If the disk is replaced, the same thing will happen. The raid software will write the missing data back using the remaining disks like the example below.

Disk1Disk2Disk3Disk4Disk5
00write 10parity bit 1
10write 1parity 00

To summarize:Even parity just counts the 1's and if it's odd, then it will add a 1 to make it even. If it's even, then it will add a 0. That's all there is to parity.

Advantages of raid 5

Unlike mirrors, where you need twice the amount of disks, with raid level 5, you only loose the space of one disk. If you have 3 100Gb disks in a raid level 5 configuration, then only 200Gb is available for use, and not 300Gb.

This is because of the parity. Using raid level 5 can be cost effective. For example, let's say you have 4 100Gb disks. If you create a mirror configuration of these disks, you would only have 200Gb usable. If you use raid level 5, then you have 300Gb usable.

The size of the disks, multiplied by the number of disks, minus the space of one disk equals the size of usable space.

It's also quite easy to configure. You will find raid 5 on software and hardware raid.

Disadvantages

There are quite a few.

The parity calculations on stripe sets puts a heavy load on the system. Write performance can be very poor with raid level 5. Remember that for every write, parity has to be calculated.

There is also another issue that people don't even know about. It's called the stripe unit size. It's also known as the block size. Let me explain.

When you create a stripe, you need to specify a stripe unit size. This is the size on each disk that the software will write to. If you add all these units together, then you get the stripe size.

When you write data to a raid 5 volume, the data is broken up into these stripe units, so that data from the application can be distributed on all disks.

Below is a picture to illustrate this.

Raid 5 stripe unit
Raid 5 stripe

In the example we were lucky, because the data that was written was exactly the size of the stripe, which was 128kb. The parity was calculated in memory and then everything was written to disk in one single operation.

What if the data from the application does not match the stripe size? If this is the case a lot of stuff has to happen before the data could be written to the disks.

Let's use an example where the data size is less than 128kb. I will use a 32kb data size. If the data size is less than half the stripe size, then the existing data has to read from the stripe that resides on the disks.

Data read from existing stripe
Raid 5 read

After the data has been read, it needs to add the new data to the stripe and modify the parity. Remember we want to write new data, so the parity will change.

Stripe modified to create new parity
Raid 5 modify

After this is finished, the data with the new parity has to be written back to disk.

New data and parity written to disk
Raid 5 write

This whole process is known as read, modify, write. As you can see, this could place a huge load on the system. Especially if your system is write intensive.

So it's important to match your data size with your stripe size. There are other scenarios such as if the data size is half or bigger than the stripe size and so on. I won't go into detail about these. In all cases, except if the stripe size matches, there will be overhead to read, modify and write the new data.

Raid 5 is not very popular on software based raid systems because of this issue. It's also difficult to get the exact data size from the application. People buy these storage arrays and then run all kinds of applications on it.

Sometimes the engineers, who set this up, try to use a best size scenario to cater for different sizes. This is not ideal.

If you don't know the data size then setup your raid 5 groups and monitor it for performance issues. Try to create a test group and test different scenarios and stripe sizes.

Raid 5 is more commonly used on hardware raid devices. The advantage with hardware raid is that the controller has its own CPU and cache or memory. So all these calculations can happen on the controller without the host even knowing about this.





Return from Raid 5 to Raid Levels

Back to What is My Computer














Search what-is-my-computer.com




What is my Computer

What is in my computer?


Computer Components

Discover what goes into a PC?