Durability: replication and erasure coding
How storage systems survive disk failures without storing three full copies of everything.
On the roadmap:Advanced · step 3: Storage engines
Lesson 14 of 23 · 7 min read · quiz · exercise
Why durability is hard
Disks fail every day in a large fleet. Durability is the probability data is not lost over time, and cloud object storage advertises numbers like eleven nines. How?
Image: Mk2010 · CC BY 4.0 · Source · Wikimedia Commons: Hard disk drive platter, Samsung MP0402H
Technique 1: replication
Keep N full copies on different machines, racks and zones. Simple and fast:
- Any copy can serve a read.
- Recovery is just copying a replica.
- Cost: 3 copies mean 3x storage.
Technique 2: erasure coding
Split an object into k data pieces, compute m parity pieces (using maths such as Reed-Solomon), and store all k + m pieces on different machines. Any k of the k + m pieces can rebuild the original.
Figure SDA-CORE-14-1 · Technique 2: erasure coding · © forcsguy.com
With (6, 3) you store 9 pieces for 6 pieces of data: 1.5x overhead, and you can lose any 3 disks. That beats 3x replication on both counts.
Figure SDA-CORE-14-2 · Surviving two failures and rebuilding · © forcsguy.com
The trade-offs
| Replication | Erasure coding | |
|---|---|---|
| Storage overhead | high (3x) | low (about 1.2x to 1.5x) |
| Read | from one copy, fast | read several pieces, fast if all data pieces present |
| Repair | copy one replica | read many pieces and recompute |
| Small updates | easy | costly (re-encode) |
| Best for | hot, small, frequently changed data | cold, large, rarely changed objects |
Making it real
- Placement: put pieces in different failure domains (disk, server, rack, zone) so one event cannot take many.
- Detection and repair: monitor continuously, and rebuild lost pieces before more fail. The faster the repair, the higher the durability.
- Checksums: verify data on read and in background scrubbing to catch silent corruption.
- Tiering: hot data replicated; older data converted to erasure coding.
- Versioning and backups protect against human error, which replication does not (a delete replicates too).
Related reading
- Uber Schemaless: A Scalable MySQL DatastoreUber Engineering · UberCase Studies
- How Discord Stores Trillions of MessagesBo Ingram · DiscordBlogs
- Jordan Has No Life: Systems Design Concepts SeriesJordan · Jordan Has No LifeYouTube
- Inside the Magic PocketDropboxCase Studies
Show 6 moreShow fewer
- Kafka Source & DocsApache Software Foundation · apacheGitHub
- Black-Box Auditing: Verifying End-to-End Replication Integrity between MySQL and Redshift at YelpYelp engineers · YelpCase Studies
- Apache CassandraApache Software Foundation · GitHubGitHub
- Types of Replication - SQL ServerMicrosoft engineers · MicrosoftCase Studies
- Concept && CodingShrayansh Jain · Concept && CodingYouTube
- Accelerator: Fast Data Processing Framework at eBayeBay engineers · eBayCase Studies
Check your understanding
Question 1 of 3
0 correct so far
What is the main advantage of erasure coding over 3x replication?
Practise it: The database goes down
Everything below is already set up for this lesson: change the design, run the traffic, and see whether you meet the goal.
- 1The task
- 2Build and test
Ten seconds in, the primary database fails. Traffic is 600 requests per second and 30% of it is writes. A failover would take a minute or more.
Goal: Keep errors under 5%: reads should keep working and writes must not be lost.
Two things can still serve while the primary is down: something that already holds a copy of the data, and something that can hold writes until the primary returns.
Try it yourself
Compare storing 100 TB with 3x replication versus a (6, 3) erasure code. How much raw storage does each need, and which failures does each tolerate?
Click what a strong design here would need:
More in Building blocks
© 2026 forcsguy.com. Original lesson text and diagrams. Books and sites linked above belong to their authors.