Thursday

Parity

Really interesting concept. It's used in hard drive RAID setups to increase the reliability of the system.

Let's say you have 3 hard drives full of important data. You want to your system to be able to withstand the catastrophic and sudden failure of one hard drive. The first thing that comes to mind is that you need to have realtime backups - 3 more hard drives of the same size, acting as duplicate backups.

Actually, you only need 1 more hard drive to ensure that none of the data on the first 3 drives are lost by a single failure, by this really neat idea called parity.

The simplest way to explain it is as such - all data in hard drives is stored as "bits", either being 0 or 1. For parity to work, all drives should be exactly the same size. Every corresponding bit in each drive is mapped together. What happens is that, the parity drive adds up all the corresponding bits across the other drives and writes a 0 if the total is even, or a 1 if the total is odd in the location where the mapped bit was. A quick example will show this.

locationhdd1hdd2hdd3parity drive
10110
21100
31001
40101

Parity is recalculated every time the computer writes data to any of the other drives. As you can see, this system is robust enough to withstand any single hard drive failing. If any one of HDD1, HDD2 or HDD3 fails, all you need to do is install a replacement, and the computer can deduce what data was supposed to be there by referring to the parity. Example, HDD1 dies. We know that HDD2 has a 1 bit and HDD3 has a 0 bit in that location, and the parity bit is 0, meaning that the total must be even, therefore HDD1 must have been a 1 bit (if HDD1 had been a 0 bit then the parity would have been 1 instead).

If the parity drive fails then you just put in a new hard drive and let the computer recalculate and write the parity data again.

It's a really neat idea, beautiful in its simplicity. I like it.

3 comments:

Anonymous said...

... it's neat... until u have to design storage facilities for clients and choosing between cost and speed and redundancy using parity n mirroring n raid 0, 1, 4, 5 n ARGHHHH!

aetherfox said...

doesn't stop it from being neat =p

xenobiologista said...

Cardboard punch cards. No way to lose your data unless they catch fire =D