RAID: Redundant Array of Inexpensive/Independant Disks Why use multiple disks? - Performance: parallel access - Reliability: can handle a disk failure - Capacity: need more disks to store more data What is a RAID? - Hardware RAID: a box you attach to a computer -- looks like a disk to the computer, but internally has lots of disks - Software RAID: runs in the OS as a layer below the file system, makes a bunch of disks attached to the PC look like one big disk Interface to RAID: - Linear array of bytes: can read, write - Simple, powerful abstraction of a disk Simplest RAID Level: RAID-0 (Striping) - Mapping: Lay out blocks across drives Disk0 Disk1 Disk2 Disk3 0 1 2 3 4 5 6 7 ... - How to calculate where a particular block is? Disk = BlockAddress % Disks Offset = BlockAddress / Disks e.g., Read block 7 Disk = 7 % 4 = 3 (Block 7 is on Disk 3) Offset = 7 / 4 = 1 (Block 7 is at offset 1 on Disk 3) Evaluate along three axes: Performance, Reliability, Capacity - RAID 0 Capacity: Great (given D disks, can use all for user data) - RAID 0 Performance: Great (can use all disks in parallel on reads/writes) - RAID 0 Reliability: Poor (one disk failure leads to entire volume corruption) Can we do better? RAID-1 (Mirroring) - Make sure each block has a copy on another disk - Example layout: Disk0 Disk1 Disk2 Disk3 0 0 1 1 2 2 3 3 ... Evaluate along three axes: Performance, Reliability, Capacity - RAID 1 Capacity: D/2 (only half of D disks is perceived as usable by user) - RAID 1 Reliability: Can tolerate any one disk failure (for sure), scheme above can tolerate D/2 failures (if lucky) - RAID 1 Performance: Good - Reads can go to all disks; Writes get half the bandwidth, because each logical write to RAID-1 leads to 2 physical writes (one to each copy) How to get better capacity? (perhaps at some performance cost?) RAID-4 (Parity) - Use parity to encode info about each block - Example layout: Disk0 Disk1 Disk2 Disk3 0 1 2 Parity(0,1,2) 3 4 5 Parity(3,4,5) ... - Parity checks the blocks in the row - How? XOR, e.g., if you have the following data (0 1 0 0) the parity would 1, such that the number of 1's in the row is even. If you had the following data (0 1 1 0), the parity bit would be 0, again to make sure the number of 1's in the row is even. Evaluate along three axes: Performance, Reliability, Capacity - RAID 1 Capacity: (D-1 of D) disks used for data - RAID 1 Reliability: Can tolerate any one disk failure - RAID 1 Performance: Good for reads (can go to all but one disk), Less good for writes (requires 2 reads and 2 writes) - Why so many reads and writes on a single write to RAID-4? Must read the old data and the old parity in order to compare the new block with the old block and hence generate the new parity. Major problem with RAID-4: Parity-disk bottleneck - All parity reads/writes must go to the parity disk Solution? RAID-5 (Rotated Parity) - Example layout: Disk0 Disk1 Disk2 Disk3 0 1 2 Parity(0,1,2) 3 4 Parity(3,4,5) 5 6 Parity(3,4,5) 7 8 Parity(3,4,5) 9 10 11 Spreads the parity across all disks (but still requires 4 I/Os per write) Conclusions: - RAID turns multiple disks into one bigger, faster, more reliable disk - RAID-0 is good when performance really matters but reliability doesn't - RAID-1 is good when capacity and cost don't matter but write performance does - RAID-5 is good for capacity and when cost matters or if workload is read-mostly