HDFS Erasure Coding for Cold Data: Storage Savings vs. Read Cost
Compare HDFS erasure coding against three-way replication for cold data in Hadoop 3.x, with CLI commands and trade-offs.
05 Oct 2026, 19:21 UTC

The storage problem on cold data
Your Hadoop cluster is running out of disk, and most of that space holds data no one reads daily. The default HDFS policy stores three copies of every block, so a petabyte of logical data consumes roughly three petabytes of disk. For cold data—logs, snapshots, and archives accessed rarely—that overhead is expensive. HDFS erasure coding in Hadoop 3.x can cut that overhead roughly in half, but it changes how reads and rebuilds work. This post walks through the decision, a directory-level configuration example, and the checks you should run before moving production data.
What erasure coding changes
Three-way replication keeps a complete block replica on three DataNodes. A read can be served from any one replica, usually the closest one. Erasure coding (EC) splits data into cells, encodes data units plus parity units using Reed-Solomon coding, and spreads the strips across DataNodes. A common policy, RS-6-3, uses six data units and three parity units. Logical data is stored across nine units instead of three full replicas, reducing storage overhead from about 200 percent to about 50 percent.
The trade-off is read amplification. Reading an erasure-coded block requires contacting multiple DataNodes to reconstruct the missing strips, which uses more CPU and network than reading a local replica. Cell striping groups blocks into strips before encoding, which affects rebuild parallelism and rack-aware placement. EC policies apply per directory and only to new files written after the policy is set; changing the policy does not retroactively re-encode existing files.
Where it fits and where it does not
EC is best suited for cold or rarely accessed data: compliance archives, old logs, and write-once datasets where storage cost dominates and read latency is not critical. It is not recommended for hot workloads or low-latency reads because reconstruction on read is more expensive than serving a local replica. Losing multiple DataNodes simultaneously can trigger costly full-stripe reconstruction and may temporarily reduce data availability during rebuild.
Worked example: enable EC on a directory
Run these commands on a gateway or edge node with the HDFS client installed. You typically need HDFS superuser permissions, or ownership of the target directory.
List supported policies:
hdfs erasurecode -listPolicies
Expected output includes policies such as RS-6-3 and RS-10-4, with cell size, data units, and parity units. Do not copy sample output into a runbook; verify it against your cluster.
Set a policy on a new cold-data directory:
hdfs erasurecode -setPolicy -policy RS-6-3 /data/archive
This affects new files under /data/archive only. Existing replicated files remain replicated until explicitly converted.
To convert an existing file, which changes state:
hdfs erasurecode -encode -path /data/archive/legacy-dataset
Risk: encoding consumes cluster resources and can affect other workloads. Run it during a maintenance window or on a test directory first.
Compare disk usage against a replicated directory:
hdfs dfs -du -s /data/archive
hdfs dfs -du -s /data/replicated
Expect the EC directory to show lower disk usage after new data is written, but do not compare until files have been rolled or encoded. Disk usage alone does not tell you about read latency.
Verify before you commit
- Run
hdfs erasurecode -listPoliciesto confirm your Hadoop 3.x release supports the policy you want. - Load a representative sample into the EC directory, run
hdfs dfs -du, and compare with a replicated directory holding similar data. - In a test cluster only, stop or decommission one DataNode and observe block reconstruction logs and CPU utilization on remaining nodes. This assesses rebuild impact without risking production data.
- Read a sample EC file and a replicated file, then compare latency. If EC read latency spikes for your access pattern, keep that workload on three-way replication.
Limitations
- EC policies are not retroactive; existing files must be explicitly encoded.
- Read amplification and reconstruction CPU make EC unsuitable for hot or latency-sensitive workloads.
- Simultaneous DataNode losses can trigger full-stripe reconstruction and temporary availability reduction.
Actionable closing
Start with one cold directory, not the whole cluster. Set RS-6-3 on /data/archive, write new data, and compare disk usage and read latency against your replicated baseline. If storage cost dominates and reads are rare, erasure coding is a reasonable default to test. If users need fast, frequent reads, stay with three-way replication.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.