Cutting HDFS Storage Costs with Erasure Coding in Hadoop 3.x
Erasure Coding in Hadoop 3.x lets you store warm and cold data at half the space of 3× replication. This post walks through policy selection, a worked example, and the operational limits you need to watch.
11 Nov 2026, 07:31 UTC

The storage problem that keeps clusters growing
Three‑way replication is simple and fast, but it triples the raw capacity you need. For petabytes of warm or cold data — logs, backups, historical analytics — that 200 % overhead becomes a budget line item you can’t ignore. Hadoop 3.x ships with HDFS Erasure Coding (EC), a block‑level alternative that can bring the overhead down to roughly 50 % while still tolerating multiple node failures.
Choosing an encoding policy
EC splits each logical block into data cells and parity cells. The policy you pick determines how many of each, the fault‑tolerance, and the CPU cost. The most common policies in 3.x are:
| Policy | Data + Parity | Failure tolerance | Typical stripe size | CPU impact |
|---|---|---|---|---|
| RS‑6‑3‑1024k | 6 + 3 | 3 simultaneous node losses | 1024 KB | Moderate (Reed‑Solomon) |
| RS‑3‑2‑1024k | 3 + 2 | 2 node losses | 1024 KB | Lower |
| XOR‑2‑1‑1024k | 2 + 1 | 1 node loss | 1024 KB | Lowest (XOR only) |
Reed‑Solomon gives the best space savings for a given fault‑tolerance but consumes more CPU on DataNodes and clients during encode/decode. XOR is lighter on CPU but only survives a single failure. Pick the policy that matches your failure‑domain design and the CPU headroom of your cluster.
Worked example: enabling EC on a cold‑data directory
The following steps assume you are running Hadoop 3.3+ (EC on encrypted zones requires 3.3) and have hdfs superuser privileges. Run them on any edge node that has the Hadoop client configuration.
# 1. Create a target directory (if it doesn’t exist)
hdfs dfs -mkdir -p /data/cold
# 2. Apply an EC policy – here RS‑6‑3 with the default 1 MB stripe
hdfs ec -setPolicy -policy RS-6-3-1024k -path /data/cold
# 3. Verify the policy is attached
hdfs ec -getPolicy -path /data/cold
# 4. Write a test file (10 MB, larger than one stripe)
hdfs dfs -put /local/path/to/10mb.dat /data/cold/
# 5. Inspect block layout – you should see one logical block split into 9 cells
hdfs fsck /data/cold/10mb.dat -files -blocks -locations
Expected check: the fsck output lists a single block with ECPolicy=RS-6-3-1024k and shows nine distinct DataNode locations (six data, three parity). If you see only three replicas, the policy was not applied — re‑run step 2.
Risks: the first write after policy change triggers encoding on the client side; on a CPU‑bound cluster this can spike load. Also, files smaller than the stripe size (1 MB by default) will not benefit and may even waste space because a full stripe is allocated.
Operational trade‑offs you must monitor
- Read latency: When all cells are local, EC reads match replicated reads. Missing cells trigger on‑the‑fly reconstruction, adding network round‑trips and CPU decode time. Keep hot datasets replicated.
- Reconstruction storms: Simultaneous DataNode losses launch many low‑priority YARN reconstruction jobs. Throttle with
dfs.namenode.ec.reconstruction.parallelism(default 10) and watch the NameNode metricECReconstructionTasksPending. - CPU pressure: Encoding on write and decoding on repair increase DataNode CPU. If your cluster already runs near 80 % CPU, add cores or reserve a subset of nodes for EC workloads.
- Small‑file penalty: Files < 1 MB occupy a full stripe but store only a fraction of the data cells, eroding the space advantage. Consider compaction (e.g.,
hadoop archiveor periodicdistcp -ec) for directories with many tiny files. - Encrypted zones: EC support arrived in 3.3. If you run 3.0‑3.2, keep encrypted data replicated.
Actionable next steps
- Spin up a three‑node test cluster (or use an existing dev cluster) and repeat the worked example.
- Run a read benchmark —
hadoop jar hadoop-mapreduce-client-jobclient.jar TestDFSIO -read -nrFiles 10 -size 100MB— against both an EC directory and a replicated directory to quantify latency overhead. - Simulate a DataNode shutdown, then monitor the NameNode UI at
/ec-reconstructionand the YARN application logs until reconstruction completes. - Validate downstream tools: create a Hive external table pointing at
/data/coldand run a simpleSELECT COUNT(*). No code changes are required, but confirm the query finishes without errors. - If the pilot meets your cost‑vs‑performance targets, roll out EC policies per dataset tier (e.g., RS‑6‑3 for archives, RS‑3‑2 for less‑critical logs) and add alerts on
ECReconstructionTasksPendingand DataNode CPU.
Erasure Coding won’t replace replication for every workload, but for the large, infrequently accessed portion of your data it can halve the storage bill with a modest operational footprint — provided you monitor reconstruction health and keep CPU headroom in mind.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.