What is erasure coding?
Erasure coding is a way to protect stored data by splitting it into k data fragments, computing m parity fragments from them, and writing all k+m fragments to different disks or servers. Any k of those fragments are enough to rebuild the original, so the data survives the loss of up to m fragments.
Think of a shopping receipt that lists four prices and the total. If a coffee stain hides one price, you can still work it out from the total and the other three. Parity fragments are that total: extra numbers computed from the data, so missing pieces can be recalculated.
Reed-Solomon is the most common code in storage systems. When a disk dies, the system knows exactly which fragments were on it and rebuilds them from any k that are left.
What does 4+2 mean?
In 4+2, each object becomes 4 data fragments and 2 parity fragments, 6 in total. k is the number of data fragments, and m is the number of disks or servers that can fail without losing data.
Raw disk use is (k+m) / k. For 4+2 that is 6 / 4 = 1.5x, so storing 1 TB takes 1.5 TB of disk, and any 2 fragments can be lost. Triple replication also survives 2 lost copies, but it uses 3x raw disk, twice as much.
Failure domains
A failure domain is hardware that can fail together, such as a disk, a server or a rack. Each fragment needs its own. With the server as the failure domain, a 4+2 pool survives two servers going down, but not the loss of the rack or site that holds all six.
Erasure coding vs replication
Replication stores full copies. Erasure coding stores fragments plus parity, so it reaches the same fault tolerance with less disk, but does more work on repair and writes.
Storage cost
A 2+2 scheme gives the same protection as three full copies, but stores 1 TB on 2 TB of disk instead of 3 TB. Wider schemes save more disk, but they need more servers or racks to hold one fragment each.
Repair
To rebuild one lost fragment, the system reads k others. With 10+4, repairing one block means transferring 10 blocks over the network. A replicated block is repaired by copying one block.
Latency and small objects
A write has to reach every fragment, so a 4+2 write lands on six devices where a triple-replicated write lands on three. Expect higher write latency, most of all on HDDs and while the system rebuilds a failed disk.
Many very small objects also waste space, because each one still becomes k+m fragments.
In practice the split usually looks like this:
- Erasure coding for large objects written once and read often, such as backups, media and logs.
- Replication for small, hot metadata.
How enum handles erasure coding
enum Object Storage uses EC 4+2 with each fragment on its own server: six servers in one rack, data on HDD and metadata on NVMe. enum states 99.9999999% durability for this design, and the 99.9% SLA covers availability. The rack and the zone are the failure boundary, so keep a second copy elsewhere of anything you cannot afford to lose.
FAQ
What happens when a fragment is lost? Reads keep working as long as k fragments are left, because the missing ones can be recomputed. The system then rebuilds the lost fragment from k of the others and writes it to another disk or server.
Why not always use a wide scheme like 17+3? 17+3 costs only 20 / 17 = 1.18x raw disk, but it needs at least 20 failure domains. Wider schemes also read more fragments to repair one, so rebuilds create more network traffic.
Does erasure coding replace backups? No. It protects against failed hardware, not against deleting or overwriting data, and not against losing the whole site. Use versioning, Object Lock and a copy in another location for that.