Cutting HDFS Storage Costs with Erasure Coding: When 1.5x Beats 3x
HDFS Erasure Coding in Hadoop 3.x cuts storage overhead from 3x replication to ~1.5x for cold data. Here's how Reed-Solomon policies work, how to apply them, and the read-performance trade-off.
03 Dec 2025, 17:52 UTC

Your Hadoop cluster is full again. The finance team wants three years of clickstream history retained, but every terabyte you keep costs three terabytes of raw disk because HDFS replicates each block three times. For data that gets written once and read maybe twice a quarter, that replication tax is hard to justify. This is exactly the problem HDFS Erasure Coding (EC), introduced in Apache Hadoop 3.0, was built to solve.
The thesis is simple: for cold, infrequently accessed data, erasure coding cuts storage overhead from 3x to roughly 1.5x while still tolerating multiple simultaneous failures — at the cost of extra CPU and network work during reads and recovery.
How Reed-Solomon replaces replication
With default replication, HDFS stores three full copies of every 128 MB block. Erasure coding instead stripes a file across a group of blocks and computes parity blocks using a Reed-Solomon codec. The default policy, RS-6-3-1024k, encodes every 6 data blocks with 3 parity blocks. Any 6 of the 9 blocks are enough to reconstruct the data, so the system tolerates up to 3 simultaneous block failures — the same failure tolerance as 3x replication — while using 1.5x storage instead of 3x.
Other built-in policies exist (for example RS-10-4, which lowers overhead to 1.4x but spreads data across more machines), but RS-6-3 is the sensible default for most clusters.
Enabling and applying a policy
Erasure coding requires Hadoop 3.x across the board — NameNode and all DataNodes. A mixed 2.x/3.x cluster will not work. On the NameNode, confirm EC is enabled (it is by default in 3.x):
hdfs getconf -confKey dfs.namenode.ec.enabledRun this on any node with the HDFS client configuration; it reads the effective config and requires no special privileges. Then, as the HDFS superuser (typically the hdfs principal), enable the policy and apply it to a directory:
hdfs ec -enablePolicy -policy RS-6-3-1024k
hdfs ec -setPolicy -path /data/cold/clickstream -policy RS-6-3-1024kKey detail: the policy applies only to new files written under that directory. Existing replicated files stay replicated. Verify what is attached to a path with:
hdfs ec -getPolicy -path /data/cold/clickstreamAfter writing new data, confirm the storage type changed:
hdfs fsck /data/cold/clickstream -files -blocksIn the fsck output, erasure-coded files report block groups with the logical block type rather than replicated blocks, and the block count reflects the striped layout. One operational gotcha: fsck on large directory trees is slow and adds NameNode load, so scope it to a sample subdirectory rather than the whole tree.
The trade-off you are accepting
Replication makes reads cheap: any one of three copies can serve the request, and a single block read is a local disk operation on one DataNode. Erasure-coded reads of healthy data are similar, but any read that requires reconstruction — a missing block, a dead DataNode — must fetch data from multiple nodes and decode it. That means more network I/O and CPU, and slower recovery when a node fails, because rebuilding a lost block group requires reading surviving blocks from several machines.
Practical consequences:
- Cold data only. Archive partitions, historical logs, compliance retention. Do not EC data feeding nightly SLAs until you have measured the read penalty in your environment.
- Small files are a poor fit. EC operates on block groups; tiny files waste parity overhead and inflate NameNode metadata. Compact small files first (HAR, sequence files, or upstream batching).
- Rack awareness matters. The 9 blocks of an RS-6-3 group must land in different failure domains. Verify your rack topology script is correct before enabling EC, or a single rack loss could take out more blocks than the policy can survive.
- Cluster size floor. RS-6-3 needs at least 9 DataNodes (ideally more, across racks) to place a full stripe.
A worked sizing example
Say you retain 500 TB of historical log data. Under 3x replication that consumes 1,500 TB of raw capacity. Converting it to RS-6-3 reduces that to roughly 750 TB — a 750 TB saving. On a cluster where disk is the binding constraint, that can defer a hardware purchase by a year or more. The cost is that a DataNode failure now triggers reconstruction reads across up to 8 other nodes instead of a simple copy from one replica, so plan decommissioning and failure windows accordingly.
Before you roll it out
Test in a non-production cluster first. Apply the policy to a representative directory, write a few hundred gigabytes, then kill a DataNode and observe reconstruction time and CPU on the remaining nodes. Check hdfs fsck output to confirm block groups are healthy, and watch DataNode metrics for reconstruction load. If misapplied to hot data, you can set the directory back with hdfs ec -unsetPolicy -path /data/hot — new writes revert to replication, though already-encoded files must be rewritten to convert back.
Start with your coldest, largest dataset, measure the capacity reclaimed and the read latency change, and expand from there. Erasure coding is one of the few storage decisions that pays for itself in hardware you never have to buy — as long as you keep it away from data that needs to be fast.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.