HDFS Erasure Coding: Trading CPU for Half Your Storage Bill
HDFS Erasure Coding in Hadoop 3.x cuts storage overhead from 3× to ~1.5× for cold data. Here's how to enable RS-6-3, verify it with fsck, and weigh the CPU and latency trade-offs.
11 Aug 2026, 04:14 UTC

If you run a Hadoop 3.x cluster with the default 3× replication, every terabyte of useful data costs you three terabytes of raw disk. For cold datasets — archived logs, historical partitions, backup dumps — that overhead is mostly insurance you rarely cash in. HDFS Erasure Coding (EC), introduced in Hadoop 3.0, cuts that overhead to roughly 1.5× while still tolerating up to three simultaneous block failures. The catch: you pay in CPU and read latency instead of disks. This post walks through when that trade makes sense and how to enable it safely.
Replication vs. erasure coding
With 3× replication, HDFS keeps three full copies of every block. Lose any two nodes and your data survives. Erasure coding instead splits data into a stripe: for the commonly used RS-6-3-1024k policy, six data blocks plus three parity blocks computed with Reed-Solomon math. Any six of the nine blocks can rebuild the original data, so you still tolerate three failures — but at 1.5× overhead instead of 3×.
The DataNodes do the encoding and decoding work, using either the native ISA-L library (hardware-accelerated) or a slower pure-Java fallback. Clients use the same DFSClient APIs, so applications don't change — but the cluster's CPU profile does.
Enabling a policy and applying it
EC is directory-scoped, which is the key operational detail: you opt in per directory, and only new files written there are encoded. Existing files stay replicated until rewritten.
Run these as an HDFS superuser (or a user with EC admin rights) from any node with the Hadoop client configured:
# Verify you're on Hadoop 3.x — the 'ec' subcommand doesn't exist on 2.x
hdfs version
# Enable the built-in RS-6-3 policy (disabled by default on many distros)
hdfs ec -enablePolicy -policy RS-6-3-1024k
# Apply it to a cold-data directory
hdfs ec -setPolicy -path /data/cold -policy RS-6-3-1024k
# Write a test file and verify the layout
hadoop fs -put localfile.100mb /data/cold/
hdfs fsck /data/cold/localfile.100mb -files -blocks -racksIn the fsck output you should see the file reported as erasure-coded with the RS-6-3-1024k policy and nine blocks per stripe (six data, three parity) spread across distinct DataNodes. If the output shows plain replicated blocks, the policy didn't take — check that it was enabled and that the file was written after the policy was set.
To convert existing replicated data, you rewrite it: distcp it to the EC directory (or use the hdfs ec -replicate path on distributions that provide it), then delete the original. There is no in-place conversion.
The trade-offs that actually bite
Read latency. Sequential reads of healthy EC data are fine, but any read that hits a missing block triggers on-the-fly reconstruction, and random reads pay decoding cost. Expect noticeably higher latency than replicated reads for cold access patterns. Benchmark with hadoop fs -cat against an equivalent replicated file before committing a workload.
Small files. A 500 KB file under RS-6-3 still occupies a full nine-block stripe and nine NameNode metadata entries. EC makes the small-files problem worse, not better. Combine small files first (sequence files, ORC, or Hadoop Archives) before landing them in EC directories.
Cluster size and rack topology. RS-6-3 needs at least nine DataNodes to place a full stripe with proper redundancy (six data plus three parity), and the stripe spreads across nodes, not racks. A single rack failure can exceed your parity budget on a default setup. If rack loss matters to you, look at rack-aware policies or accept the risk explicitly.
CPU and reconstruction storms. Confirm ISA-L is installed on every DataNode (ldconfig -p | grep isal); the Java fallback is dramatically slower and can bottleneck ingest. When a node dies, reconstruction is CPU- and network-hungry. Watch the NameNode's ECBlockGroup metrics via JMX — a growing reconstruction backlog means DataNodes can't keep up, and you may need to throttle with dfs.datanode.ec.reconstruction.xmits.weight.
A sensible rollout
Start with one genuinely cold directory: last year's logs, a backup landing zone. Enable the policy, migrate data with distcp, verify with fsck, and decommission one test DataNode to watch reconstruction behave. Compare storage before and after — the savings are immediate and measurable. If read latency on that data is acceptable for your access patterns, expand to the next tier. Keep hot datasets, small-file-heavy trees, and anything latency-sensitive on 3× replication.
One last caveat: EC protects against hardware failure within the parity budget — nothing more. It does not protect against accidental deletion, corruption, or cluster loss. Snapshots and off-cluster backups remain your job. Used for the right data, though, EC is one of the few Hadoop features that pays for itself in hardware you never have to buy.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.