And finally, let's talk about Raid 5, which uses a technique
called distributed block-interleaved parity to protect the disks.
It does block-interleaved parity just like Raid 4, but
its parity is not all on the same disk, it is spread among all the disks.
So when we have four disks, the first set of stripes,
in Raid 5, will be exactly the same as in RAID 4.
There will be 3 stripes of data on the first 3 disks.
And the parity for these stripes.
Which is computed by XORing the data bit by bit In the three stripes,
and the resulting parity stripe is written to the fourth disk.
But Raid 4 would do the same thing and put the next parity here as well.
In contrast, Raid 5 puts the next parity strip not here, but on the next disk.
So we get 3 data stripes on these disks now and their parity is here.
Then for the next set of stripes we again move the parity to another
disk and then for the next set of stripes the parity moves again, and
then for the next set of stripes the parity would again be here.
And so on.
So as you can see, the block-interleaved parity,
what it really does is it gets the parity here, and
then here, and then here, and then here.
And then again, here.
So each of the disks will get its fair share of parity.
But for each set of stripes,
we will have three stripes in this case in the parity block.
It's just that the max set of four will have a parity in a different place.
So what we get is the read performance where all four disks can actually
be used for reading data, and we get N times the throughput of one disk.
Remember that rate four was getting N minus one times
the throughput of one disk, because one of the disks was not used for data.
Here the data is spread over all four disks.
So chances are of all the blocks we want to read
they will be equally distributed among the four disks in this case.
Write performance is still affected by having to read and
then write the data in the parity.
So a single write results in four accesses.
If you remember, we will read the data block in the parity and
then we would write the data block in the parities.
So there are four accesses per write but they're distributed among all the disks.
So we get N over four times the throughput of one disk.
In this case we have four disks so right performance
is equal to the throughput of one of the disks if it was used without RAID.
Remember that in RAID 4,
our write performance is always limited to half the throughput of one disk.
In this case it would be
half of the performance of one disk versus the full performance of one disk.
So we win.
If we had for example eight disks,
here we would get twice the throughput of one disk, with RAID four,
the eight disks would still have a single parity disk and
the write performance would still be half the throughput of that one disk.
And the reliability of RAID 5 Be the same as RAID 4.
This fails if we lose more than one disk.
Just like in RAID 4, in any group of four stripes here,
we could lose one of the disks.
If we lose the parity disk, we can still read everything and write.
If we lose a data disk, we can reconstruct the data using the parity.
Here, any one of the disks play the role of a data disk in some
group of stripes and play the role of a parity disk in some groups of stripes.
So all groups of stripes are still usable after we lose only one disk.
If we lose two disks, however, then we have a problem.