Erasure-Coding Playground
Reed–Solomon over GF(256): encode data into k + m shards, lose some, rebuild it.
How it works
Splits your text or bytes into k data shards, adds m Reed–Solomon parity shards computed over GF(256), lets you drop any shards and reconstructs the original from any k survivors. Shows the generator and decoding matrices, the shard bytes in hex, and compares storage overhead and fault tolerance with replication and RAID-5 style XOR parity.
- Arithmetic is in the finite field GF(2^8) with the primitive polynomial x^8 + x^4 + x^3 + x^2 + 1 (0x11d): addition is XOR, multiplication uses log/antilog tables of the generator 2.
- The data is split into k equal shards (zero-padded at the end). The n × k generator matrix is the k × k identity (so data shards are stored as is: a systematic code) on top of an m × k Cauchy matrix C[i][j] = 1 / (x_i + y_j) with x_i = k + i and y_j = j.
- Every k × k submatrix of this generator is invertible, so any k of the n = k + m shards are enough (the code is MDS). Reconstruction inverts the rows of the surviving shards by Gauss–Jordan elimination over GF(256) and multiplies the survivors by that inverse.
- RAID-5 style parity is the XOR of all data shards: it survives exactly one lost shard. Replication keeps m + 1 full copies, survives m losses, but costs (m + 1)× storage.
Sources
- Reed, I. S.; Solomon, G. (1960): Polynomial Codes over Certain Finite Fields (J. SIAM 8(2))
- Plank, J. S. (2013): Erasure Codes for Storage Systems: A Brief Primer (USENIX ;login:)
Use this tool in an app
These free programs for your browser have this tool built in, next to everything else the task needs.
-
Proofline Math notebook
Solve, graph, test and visualise in one notebook — with data, findings and a report.
Related tools
- Number-Theory Lab – Primality, factorisation, gcd, modular arithmetic, CRT, φ, π(n), Collatz, continued fractions.
- Floating-Point Explorer – See how IEEE-754 half/single/double store a number: bits, exact value, ULP, rounding error.
How to use the Erasure-Coding Playground
See Reed–Solomon erasure coding work byte by byte: split data into k + m shards, delete some, rebuild it, and compare with replication and RAID-5.
What it is for
Storage systems from RAID arrays to cloud object stores face the same question: how do you survive lost disks or servers without storing everything three times? Erasure coding is the usual answer. The data is split into k data shards and m parity shards are added. Any k of the k + m shards are then enough to rebuild the original. With RS(6,3) you store 1.5× the data and survive three lost shards. Triple replication costs 3× and survives only two.
This playground lets you watch it happen on real bytes. Type text or hex, choose k and m, name the shards you "lose", and the tool encodes the data with Reed–Solomon over GF(256), reconstructs it from the survivors and shows the shard bytes, the generator matrix and the decoding matrix. It's a learning tool, not a storage library. Input is limited to 4,096 bytes.
Worked example
Example 1: the text "Hello, erasure coding!" (22 bytes) with k = 4, m = 2, losing D1 and D3.
Result: "RS(4,2): after losing D1, D3, the 22 bytes were reconstructed from D2, D4, P1, P2." The reconstructed text matches the original.
- Each shard is 6 bytes. 22 bytes don't divide by 4, so the last shard was zero-padded by 2 bytes, and the padding is removed after decoding.
- The data shards are plain slices of the input (D1 =
48 65 6c 6c 6f 2c= "Hello,"). The code is systematic, so you can read the data directly when nothing is lost. - The parity shards look random: P1 =
20 56 84 ad f3 a6.
The comparison table puts this in context:
| Scheme | Storage | Survives | Stored bytes |
|---|---|---|---|
| Replication (3 copies) | 3× | 2 losses | 66 |
| RAID-5 style XOR (4+1) | 1.25× | 1 loss | 30 |
| Reed–Solomon RS(4,2) | 1.5× | 2 losses | 36 |
Example 3 shows the limit. RS(3,2) with three shards lost is "unrecoverable (shards lost: 3; tolerated: 2)". With m parity shards you survive m losses and not one more.
How to read the result
- Shards: every data (D) and parity (P) shard in hex, with lost ones marked.
- Generator matrix: the identity on top (data stored as is) and the Cauchy rows that compute parity underneath.
- Decoding matrix: the inverse built from the surviving rows. Multiplying the survivors by it gives back the data shards.
- Comparison: storage overhead, tolerated losses and repair reads. Rebuilding one lost RS shard means reading k other shards, while replication needs just one copy. That's the hidden cost of erasure coding.
Tips and common mistakes
- Overhead is (k + m) ÷ k. RS(10,4) costs 1.4× for four losses, but every repair reads ten shards, so wide stripes save space and cost network traffic.
- Erasure coding recovers known missing shards (erasures). It doesn't detect silently corrupted ones. Real systems add checksums per shard.
- Try losing only parity shards. Nothing needs to be computed, because the data shards are intact.
- Use hex input to test edge cases such as all zeros or a single byte.
- m = 0 gives no protection at all. m = 1 behaves like RAID-5 parity in terms of fault tolerance.
FAQ
Why can any k shards rebuild the data?
The generator uses a Cauchy matrix, and every k × k submatrix of the full generator is invertible over GF(256). Whichever k rows survive, their matrix can be inverted. This property is called MDS (maximum distance separable).
What is GF(256)?
A finite field with 256 elements, one per byte value. Addition is XOR, and multiplication uses log tables of a primitive polynomial (here 0x11d). Every non-zero element has an inverse, which is what makes the matrix inversion possible.
Is this how real storage systems do it?
The principle is the same as in many RAID-6 implementations and object stores. Production code adds checksums, much larger shards and optimised arithmetic.
What do "repair reads" mean?
The number of shards that must be read to rebuild one lost shard: k for Reed–Solomon and XOR parity, 1 for replication.
Guide last updated:
For scripts and AI agents
- JSON API:
POST https://erasurecodingplayground.usefulweb.site/api/v1/calculate(same calculation as this page) - Interface description: OpenAPI 3.1 · AI guide: llms.txt
- MCP server (Streamable HTTP):
https://erasurecodingplayground.usefulweb.site/mcp· tool nameerasure_coding_playground
Example request
curl -s -X POST https://erasurecodingplayground.usefulweb.site/api/v1/calculate \
-H 'content-type: application/json' \
-d '{"data":"Hello, erasure coding!","encoding":"text","k":4,"m":2,"lost":"D1, D3"}'