Skip to main content
SDMastery
advanced12 min readUpdated 2026-06-08

Erasure Coding

Learn Erasure Coding for distributed storage — achieve fault tolerance with less storage overhead than replication by encoding data into fragments that.

Diagram showing the key components and data flow in a Erasure Coding system design
High-level overview of Erasure Coding
Erasure Coding

Erasure coding is a data protection technique that splits data into fragments, expands them with redundant parity fragments, and distributes them across storage nodes. Unlike simple replication which stores complete copies, erasure coding uses mathematical encoding so that any subset of fragments can reconstruct the original data. A common configuration like Reed-Solomon (10,4) splits data into 10 data fragments and 4 parity fragments — any 10 of the 14 fragments can recover the full data, tolerating 4 simultaneous node failures with only 1.4x storage overhead instead of 3x for triple replication.

AspectDetails
What it isA mathematical technique that encodes data into n+k fragments where any n fragments can reconstruct the original, providing fault tolerance with lower storage overhead than replication
When to useWhen storing large volumes of data where 3x replication overhead is cost-prohibitive but high durability is still required — cloud object storage, archival, HDFS
When NOT to useWhen low-latency reads are critical and data is small — decoding from multiple fragments adds latency compared to reading a single replica; replication is simpler and faster
Real-world exampleFacebook (Meta) saved over 50% of their cold storage capacity by switching from 3x replication to Reed-Solomon erasure coding for their data warehouse
Interview tipExplain the storage efficiency advantage with numbers — RS(10,4) gives 4 failure tolerance at 1.4x overhead versus 3x for replication — and discuss the read latency tradeoff
Common mistakeChoosing fragment counts without considering failure domains — if 5 of 14 fragments are on the same rack, a single rack failure can lose data despite mathematical tolerance
Key tradeoffStorage efficiency vs. read performance — erasure coding saves storage dramatically but requires reading from multiple nodes and computing a decode to reconstruct data

Why This Matters

Storing data reliably across distributed nodes traditionally uses replication — keeping 3 copies provides tolerance for 2 node failures but triples storage costs. At petabyte scale, this is enormously expensive. Erasure coding provides equivalent or better durability at a fraction of the storage overhead. A Reed-Solomon (10,4) code stores 14 fragments totaling 1.4x the original data size while tolerating any 4 fragment losses — compared to 3x overhead for triple replication with only 2 failure tolerance. The tradeoff is computational: writing requires encoding across fragments, and reading may require decoding from multiple nodes. Cloud storage providers like AWS S3 and Azure Blob Storage use erasure coding internally to achieve 99.999999999% (11 nines) durability while keeping storage costs manageable at exabyte scale.

System architecture diagram for Erasure Coding showing how services, databases, and caches connect
System architecture for Erasure Coding

The Building Blocks

  • Data Fragments: The original data split into k equal-sized pieces, each containing a portion of the source data that will be distributed across storage nodes
  • Parity Fragments: Additional m fragments computed using mathematical encoding (typically Reed-Solomon) from the data fragments, providing redundancy for reconstruction
  • Encoding: The mathematical process of generating parity fragments from data fragments using Galois field arithmetic, creating the redundancy needed for fault tolerance
  • Reconstruction: The ability to recover the original data from any k of the total k+m fragments, using matrix inversion on the encoding coefficients
  • Fragment Placement: Strategic distribution of fragments across failure domains (different racks, zones, regions) to ensure that correlated failures cannot destroy more fragments than the code tolerates

Under the Hood

Erasure coding works through linear algebra over finite fields (Galois fields). In a Reed-Solomon (k,m) code, the original data is divided into k equal-sized data fragments. An encoding matrix (a k+m by k matrix based on Vandermonde or Cauchy matrices) is multiplied by the data fragments to produce k+m total fragments — the original k data fragments plus m parity fragments. The mathematical property guarantees that any k of the k+m fragments contain enough information to solve the system of equations and recover all original data.

Step-by-step diagram showing how Erasure Coding processes a request from start to finish
How Erasure Coding works step by step

Reconstruction uses the inverse of a k-by-k submatrix selected from the encoding matrix, corresponding to the k available fragments. This matrix inversion and multiplication recovers the missing fragments. When all data fragments are available (no failures), reconstruction is unnecessary — the data is read directly. When data fragments are missing, the decoder reads k available fragments (possibly including parity) and computes the missing ones. This decode step adds CPU overhead and cross-node read latency.

The critical operational consideration is failure domain alignment. In a (10,4) configuration, fragments must be placed across at least 14 independent failure domains. If a single rack holds 3 fragments and loses power, only 11 remain — still sufficient. But if placement is careless and 5 fragments share a failure domain, a single failure loses them all and data is unrecoverable. Modern systems like HDFS erasure coding and Ceph enforce placement policies that distribute fragments across racks or availability zones, ensuring that correlated failures cannot exceed the coding tolerance.

How Companies Actually Do This

Amazon S3 uses erasure coding internally to achieve 11 nines of durability across availability zones while maintaining cost efficiency at exabyte scale storage

Comparison table for Erasure Coding contrasting approaches, tradeoffs, and when to use each
Comparing key aspects of Erasure Coding

Facebook Saved over 50% of storage for their cold data warehouse by replacing 3x replication with Reed-Solomon erasure coding, recovering petabytes of capacity

Microsoft Azure Blob Storage uses Local Reconstruction Codes (LRC), an optimized erasure coding scheme that reduces cross-rack repair traffic compared to standard Reed-Solomon

Common Pitfalls

  1. Placing too many fragments in the same failure domain (rack, availability zone) — a single correlated failure can exceed the code's tolerance even though enough total fragments exist elsewhere
  2. Using erasure coding for frequently accessed hot data where the decode overhead significantly impacts read latency — replication is better for latency-sensitive workloads
  3. Not accounting for repair bandwidth — when a node fails, reconstructing its fragments requires reading k fragments from other nodes, which can saturate network links in large clusters
Data flow diagram for Erasure Coding showing how requests and responses move through the system
Data flow through Erasure Coding

Interview Questions Worth Practicing

  1. How does erasure coding achieve the same durability as triple replication with lower storage overhead?
  2. What is the read latency tradeoff of erasure coding versus replication, and when does it matter?
  3. How do failure domains affect fragment placement strategy in an erasure-coded storage system?

The Tradeoffs

  • Storage Efficiency vs. Read Latency: Erasure coding uses 1.4-1.8x storage versus 3x for replication but reading degraded data requires fetching k fragments and decoding, adding latency
  • Durability vs. Repair Cost: Higher parity ratios tolerate more failures but require more fragments for repair, consuming more network bandwidth when a node is lost
  • CPU vs. Disk: Encoding and decoding require non-trivial CPU computation on Galois field arithmetic; this is acceptable for throughput-oriented storage but not for latency-sensitive reads
Component diagram for Erasure Coding showing each building block and its responsibility
Key components of Erasure Coding

How to Explain This in an Interview

Here is how I would explain Erasure Coding in a system design interview:

Erasure coding protects data by splitting it into k data fragments and computing m parity fragments using Reed-Solomon encoding. Any k of the k+m total fragments can reconstruct the original data. For example, RS(10,4) tolerates 4 simultaneous failures at only 1.4x storage overhead, compared to 3x for triple replication which only tolerates 2 failures. AWS S3 uses erasure coding to achieve 11 nines of durability. The tradeoff is read latency — accessing degraded data requires reading from multiple nodes and decoding. Fragment placement across independent failure domains is critical — if too many fragments share a rack, a single rack failure can exceed the coding tolerance. I would use erasure coding for large cold data and replication for hot, latency-sensitive data.

Interview preparation checklist for Erasure Coding with key points to mention and mistakes to avoid
Interview tips for Erasure Coding

The Real-World Incident That Made This Famous

Understanding Erasure Coding became critical after multiple high-profile production incidents at major tech companies. When systems handle millions of users, even small misunderstandings about Erasure Coding can lead to cascading failures that cost millions in lost revenue and erode user trust. Companies like Netflix, Google, Amazon, and Meta have all invested heavily in mastering Erasure Coding because they learned the hard way that ignoring it leads to outages.

The key lesson from these incidents: Erasure Coding is not just a theoretical concept — it is a practical skill that separates engineers who build resilient systems from those who build fragile ones. Every major outage report from the past decade involves at least one Erasure Coding-related design decision that was either implemented incorrectly or overlooked entirely during the initial architecture review.

Decision guide for when to choose Erasure Coding and when alternative approaches are better
When to use Erasure Coding

How Senior Engineers Think About This

Senior engineers approach Erasure Coding differently from textbook definitions. Instead of memorizing rules, they build mental models. They ask: "What problem does Erasure Coding solve? When does it fail? What are the alternatives?" This problem-first thinking leads to better design decisions because every system has unique constraints.

When evaluating Erasure Coding in a system design context, experienced engineers consider the failure modes first. What happens when this component goes down? How does the system degrade? Is the degradation graceful or catastrophic? These questions reveal more about your understanding than any textbook definition.

The key difference between junior and senior engineers when it comes to Erasure Coding: juniors focus on the happy path, while seniors design for what happens when things go wrong. They consider operational cost, team expertise, monitoring requirements, and how the decision will look six months from now when traffic has grown 10x.

Tradeoff analysis for Erasure Coding listing advantages, disadvantages, and real-world considerations
Advantages and disadvantages of Erasure Coding

Common Interview Mistakes

Mistake 1: Giving a textbook definition without context. Interviewers want to see you connect Erasure Coding to real systems and real problems. Instead of reciting definitions, explain when and why you would use Erasure Coding in the system you are designing.

Mistake 2: Not discussing trade-offs. Every design decision involving Erasure Coding has trade-offs. Discuss what you gain and what you give up. Acknowledge the downsides and explain why the benefits outweigh them for your specific use case.

Mistake 3: Overcomplicating the solution. Start with the simplest approach to Erasure Coding that meets the requirements, then add complexity only when justified. Many candidates jump to complex implementations when a simpler solution would work perfectly.

Production deployment examples of Erasure Coding at companies like Netflix, Google, and Amazon
Real-world examples of Erasure Coding

Production Checklist

  • Define clear metrics for measuring the effectiveness of your Erasure Coding implementation
  • Set up monitoring and alerting that specifically tracks Erasure Coding-related failures
  • Document your Erasure Coding design decisions in Architecture Decision Records (ADRs)
  • Test failure scenarios related to Erasure Coding in staging before production deployment
  • Review and update your Erasure Coding implementation quarterly as system requirements evolve
  • Train new team members on the specific Erasure Coding patterns used in your system
  • Establish runbooks for common Erasure Coding-related incidents and recovery procedures

Practical Implementation for .NET Developers

In .NET, erasure coding libraries include the ISA-L (Intel Storage Acceleration Library) accessed via P/Invoke for high-performance Reed-Solomon operations. The JerasureSharp and reed-solomon-net NuGet packages provide managed implementations. For Azure, the storage SDK (Azure.Storage.Blobs) transparently benefits from Azure's internal erasure coding — LRC is handled at the infrastructure level. For custom implementations, Span<byte> and SIMD intrinsics via System.Runtime.Intrinsics enable vectorized Galois field operations. MinIO's .NET SDK (Minio) accesses MinIO object storage which uses erasure coding for on-premise deployments.

ASP.NET Core setup: Create a service class that encapsulates the logic, register it with dependency injection, and inject it into your controllers or minimal API endpoints. The built-in DI container handles lifecycle management.

Entity Framework Core: For database interactions, EF Core provides the ORM layer. Use migrations for schema management and raw SQL for performance-critical queries. Consider Dapper for read-heavy paths where EF Core overhead matters.

Azure integration: If deploying to Azure, leverage managed services — Azure Cache for Redis, Azure SQL, Azure Service Bus, Azure Cosmos DB. These eliminate operational overhead and provide built-in monitoring through Application Insights.

Testing: Use xUnit with Testcontainers for integration tests that spin up real databases in Docker. Mock external dependencies with NSubstitute. The WebApplicationFactory class lets you test your entire HTTP pipeline in-process.

Monitoring: Add Application Insights telemetry to track request latency, dependency calls, and custom metrics. Use structured logging with Serilog to make production debugging possible:

text
Log.Information("Processing {Operation} for {ResourceId}", operation, resourceId);

This gives you searchable, structured logs in Azure Monitor or Seq.