DEV Community

gxqwb
gxqwb

Posted on

Erasure Coding vs Triple Replication: What Your Storage Cluster Is Really Paying For

Every storage system makes a promise that sounds absolute: your data will still be there next year. The promise is kept by redundancy, and redundancy comes in two broad families. One of them is so simple that an engineer can explain it in a sentence; the other is a family of codes that turns storage into a small arithmetic problem. The choice between them shapes the cost, the latency, and the failure behavior of everything above it.

Triple replication buys durability with three copies of the data and cheap repairs, while erasure coding buys it with arithmetic and repair traffic, so the two schemes fail in different currencies.

Part One: Copies versus fragments

Triple replication is exactly what it sounds like. Every object is written three times to three different machines, ideally in three different failure domains. A read can go to the nearest copy, a write waits for all three acknowledgements, and a lost disk is repaired by copying one surviving replica to a new location. There is no encoding step, no decoder to trust, and no subtle math in the recovery path.

Erasure coding replaces copies with a code. A Reed-Solomon scheme written as ten plus four splits an object into ten data fragments and computes four parity fragments, so any ten of the fourteen can reconstruct the original. The mathematical property that makes this work is called maximum distance separability: the scheme tolerates the loss of exactly the number of parity fragments it stores, with no wasted redundancy. Place those fourteen fragments across racks or availability zones and the system survives several simultaneous failures that would destroy a naive replica set.

The intuition matters more than the notation. Replication asks how many complete copies you can afford. Erasure coding asks how many pieces you can lose before reconstruction becomes impossible, and then stores just enough parity to cover that number.

Part Two: The arithmetic at scale

Take an order-of-magnitude example. A cluster holding one hundred petabytes of logical data needs three hundred petabytes of raw disks under triple replication. A ten-plus-four code needs about one hundred and forty petabytes. The difference, roughly one hundred and sixty petabytes, is not a rounding error: at a few tens of dollars per terabyte per year all-in, that is on the order of several million dollars annually in disks, power, and floor space. The global market for object and cloud storage infrastructure is measured in the tens of billions of dollars per year, which is why this arithmetic gets revisited at every generation of hardware.

Repair is where the picture gets less flattering. Losing one fragment of a ten-plus-four stripe means reading any ten surviving fragments, each one tenth of the object, and running a decoder to rebuild the missing piece. The total bytes read are comparable to copying one full replica, but the operation touches ten machines instead of one, opens ten network flows, and spends CPU on Galois field arithmetic instead of a memory copy. Replication repairs by reading one source and writing one destination; erasure coding repairs by assembling a committee.

At a hundred-petabyte scale the raw disk saved by a ten-plus-four code is enough to pay for a small team, but only if the workload tolerates the extra reads and arithmetic during repair.

That condition is why real systems use variants. Locally reconstructable codes group fragments into small local sets so a single loss can be rebuilt from three or four peers rather than ten, trading a little extra parity for a much shorter repair. Modern CPUs also accelerate the finite-field multiplications with vector instructions, pushing encode throughput into the gigabytes per second per socket, but the work is still there and it competes with application traffic.

Durability deserves an honest comparison too. On paper, both schemes can advertise eleven nines or better when disk failures are independent and repair is prompt. In practice the dominant incidents are correlated: a rack loses power, a zone is misconfigured, a software bug corrupts a whole cohort. Replication spread across three zones handles a single zone loss well but is fragile if an operator places all copies in one region. Erasure coding spreads across more domains and tolerates more losses, but a bad placement policy can quietly defeat the code. Neither scheme survives a mistake in the control plane that deletes the wrong objects.

Part Three: Where each design earns its keep

Replication wins on hot data. Reads are simple, the nearest copy can serve them, there is no decode latency, and a small object does not pay a fragmentation penalty. Workloads with frequent overwrites also favor replication, because changing one fragment of an encoded stripe may require rereading and rewriting the whole stripe. Operationally, a replica set is easy to debug: the on-call engineer can inspect three files instead of reasoning about parity.

Erasure coding wins on large, immutable, capacity-hungry datasets. Object stores hold cold data that is written once and read rarely, which is exactly the case where cheap capacity matters more than fast repair. Distributed file systems have moved in this direction over time: an early design built on three replicas gives way to an encoded cold tier once the cluster reaches a scale where the disk bill dominates. The global pattern is a tiered one, with hot data replicated and cold data encoded.

The CPU cost is smaller than it used to be but not zero. An encode path that once consumed a core per gigabyte now runs on vectorized library code, yet a busy ingest pipeline still has to budget for it. Teams that enable erasure coding without measuring ingest throughput often discover the bottleneck in the storage nodes, not on the network.

Part Four: An everyday analogy

Imagine a small courier firm that must keep important contracts safe. The replication approach puts an identical signed copy in three offices across the city. If one office burns down, the manager drives to another and makes a photocopy. It wastes two filing cabinets out of three, but recovery takes one trip and no special skill.

The erasure-coding approach shreds every contract into ten numbered pieces and stores four spare pieces, fourteen fragments spread across fourteen offices. Any ten pieces are enough to reassemble the whole document, so the firm survives four offices going dark with far less cabinet space. Recovery, however, means phoning ten offices, collecting ten fragments, and running them through a machine that puts them back in order. The paper bill is lower; the phone bill and the work are higher. A smart firm keeps the contracts it needs every hour in triplicate and applies the shredding scheme to the ones nobody expects to open again.

What is actually transferable

Count network flows, not just bytes. A repair that reads the same number of bytes as a copy can still saturate a different part of the network because it talks to ten machines at once.

Match the scheme to the access pattern. Frequently updated, latency-sensitive data wants replication; large, cold, write-once data wants a code. Most real clusters want both, divided by tier.

Finally, place fragments with failure domains in mind. Redundancy is only as good as the independence of the locations holding it, and no code can compensate for a placement policy that puts every piece in the same rack.

Replication and erasure coding are not competing definitions of durability but different ways of paying for it, with disk space on one side and bandwidth plus CPU on the other.

Buy the cheaper currency only when your workload can spend the other one.

SOL: HCqPmPJM3NVtS6YrmVaTZYnuP8XZ2PFgQZKT94VK1LkS
Creating this takes real effort — thank you for the support.

Top comments (0)