Survive lost disks using clever maths, with less extra space than full copies.
Erasure coding protects data from lost disks without making full copies. It cuts data into k data pieces, adds m parity pieces made by maths, and stores all k + m pieces on different disks.
The simple way to survive a broken disk is replication: keep 3 copies. It is easy and fast, but you pay for 3x the space. For petabytes of data, that is a huge bill.
An erasure code gets the same safety with less space. It is the same idea as a crossword puzzle with some letters wiped out: if the rest of the puzzle carries enough clues, you can fill in the gaps. In storage, the "clues" are parity pieces, computed from the data. The word "erasure" means we know which piece is lost (the disk is dead), which is easier than finding hidden errors.
| Code | Idea | Good and bad |
|---|---|---|
| XOR parity (RAID 5) | One parity piece, the XOR of the data pieces. Survives one loss. | Very simple and cheap. Only one failure allowed. |
| Reed-Solomon (k, m) | Treats the data as numbers in a special number system (a Galois field). Makes m parity pieces. Any k of the k + m can decode. Survives m losses. | The classic choice. Repair needs k pieces read. |
| Local reconstruction codes (LRC) | Adds small local parity groups, so a single failure needs only a few pieces to repair, plus global parity for bigger failures. | Cheaper repair. Slightly more space than Reed-Solomon. Used in Azure and Facebook designs. |
| Regenerating codes | Research designs that reduce the data moved during repair. | Less repair traffic. More complex. |
| Fountain / rateless codes | Make an endless stream of coded pieces. Any enough of them rebuild the data. | Used in broadcasting and some transfers. |
| Layout (k + m) | Space | Survives | Notes |
|---|---|---|---|
| 3 copies | 3.0x | 2 lost | Not erasure coding, shown for comparison. Fast reads, simple repair. |
| 4 + 2 | 1.5x | 2 lost | Common in small clusters (Ceph example). |
| 6 + 3 | 1.5x | 3 lost | HDFS built-in policy RS-6-3. |
| 10 + 4 | 1.4x | 4 lost | Seen in large warehouses (Facebook HDFS RAID used 10+4). |
| 12 + 4 | 1.33x | 4 lost | Needs at least 16 failure domains. |
The rule for this kind of code (called MDS, such as Reed-Solomon): any k of the k+m pieces can rebuild the data. The loss chance assumes disks fail independently with the chance you picked. Real systems repair fast and spread pieces over racks and zones, so real numbers differ. Notice how 3 copies (1 data + 2 extra) costs 3x, while 6+3 survives more failures for only 1.5x.
| Term | Meaning in easy words |
|---|---|
| Erasure code | A way to add parity pieces so that lost pieces (erasures) can be rebuilt |
| k | The number of data pieces. Any k pieces are enough to rebuild the data. |
| m | The number of parity pieces. This is how many losses can be survived. |
| Parity | Extra information computed from the data pieces, used to rebuild lost ones |
| Reed-Solomon | The classic erasure code. Uses arithmetic in a Galois field, a number system with a finite size. |
| XOR | A bit operation that is 1 when two bits differ. The simplest parity. |
| Storage overhead | Total stored size divided by original size, (k + m) / k |
| Stripe | One group of k data cells plus its m parity cells |
| Degraded read | A read made while some pieces are missing, so decoding is needed |
| Repair / reconstruction | Rebuilding lost pieces onto new disks |
| Failure domain | A set of things that fail together, like a disk, a server, a rack or a zone |
| MDS code | Maximum distance separable: the best possible code, where any k of k + m pieces work |
| LRC | Local reconstruction code: adds local parity so a single repair reads fewer pieces |
| Choice | We gain | We lose |
|---|---|---|
| Larger k, same m | Lower storage overhead | More pieces to read per repair, more failure domains needed |
| Larger m, same k | Survives more failures | More space and more encode work |
| Erasure coding instead of copies | About half the space or less | CPU, repair traffic, slower degraded reads |
| Replicate hot, code cold | Fast reads for hot data and low cost for cold | Two systems and a migration step |
| LRC instead of Reed-Solomon | Cheaper single-piece repair | A little more space, more complexity |
| Spread over zones | Survives a zone loss | Cross-zone traffic costs and latency |