HDFS Erasure Coding for Cold Data: Cutting Storage Overhead Without Breaking Reads
Triple replication costs 200 percent overhead for cold HDFS data. Erasure coding in Hadoop 3.x drops that to roughly 50 percent, but adds read and reconstruction cost. Here is how to decide, configure, and verify.
29 Oct 2025, 04:28 UTC

Cold data is quietly expensive. If you store three copies of every file in HDFS, a 10 TB archive consumes 30 TB of raw disk before you account for filesystem overhead. For datasets you write once and read rarely, that 200 percent storage overhead feels like a tax. Apache Hadoop 3.x includes a supported alternative: erasure coding (EC). The trade is direct—you reduce storage overhead to roughly 50 percent, but reads and block recovery become more expensive. The engineering decision is not whether EC saves space; it is whether your workload can tolerate the read cost.
This article walks through the practical decision to use EC for cold data, the configuration commands that matter, and the verification steps that keep you out of trouble.
What erasure coding actually changes
Under standard replication, HDFS stores each block as a full copy. With three-way replication, every byte exists three times. Erasure coding takes a different approach: it splits a file into striped cells and computes parity blocks using a Reed-Solomon scheme. The default policy in Hadoop 3.x, RS-6-3-1024k, divides a stripe into six data cells and three parity cells, with a default cell size of 1024 KB.
In practice, this means a file is no longer a set of identical replicas. It is a mathematical construction. Any six of the nine cells can reconstruct the original data. That property is what cuts storage overhead from roughly 200 percent to about 50 percent, but it also means reads are no longer a simple local cache hit or remote replica fetch.
| Aspect | 3x Replication | Erasure Coding (RS-6-3-1024k) |
|---|---|---|
| Storage overhead | ~200% | ~50% |
| Read path | Local or remote replica | Reconstruct from stripe cells |
| Recovery traffic | Copy one replica | Read all remaining cells in stripe |
| Best fit | Hot data, write-ahead logs | Cold, immutable data |
The hidden cost: reads and reconstruction
EC is poorly suited for low-latency or frequently appended workloads. When a client reads an erasure-coded file, the client must gather enough cells to satisfy the stripe. If some cells are unavailable or the read spans multiple DataNodes, the client reconstructs missing portions on the fly. That reconstruction consumes CPU and network bandwidth.
The cost becomes sharper during failure recovery. With replication, losing one DataNode means the NameNode instructs another DataNode to copy a single replica. With EC, reconstructing one missing block requires reading all remaining cells in that stripe. A single missing block can therefore trigger a full stripe read, multiplying rebuild traffic.
This is why EC should not be enabled for hot data, HBase write-ahead logs, or latency-sensitive MapReduce inputs. Those workloads need predictable, fast reads and cheap recovery. Cold archives, compliance data, and old snapshots are the natural fit.
A worked example: applying and verifying an EC policy
EC policies are applied at the directory level and affect only newly created files. Existing replicated files are not converted automatically. The following commands run on an HDFS client or edge node. Setting a policy typically requires HDFS administrative privileges, such as the superuser or a user with ADMIN permission on the target directory.
# List available policies
hdfs ec -listPolicies
# Create a test directory and apply the policy
hdfs dfs -mkdir -p /path/to/cold-data
hdfs ec -setPolicy -path /path/to/cold-data -policy RS-6-3-1024k
# Confirm the policy on the directory
hdfs ec -getPolicy -path /path/to/cold-data
# Write a file; new files inherit the directory policy
hdfs dfs -put /path/to/local-file /path/to/cold-data/
# Inspect the block layout
hdfs fsck /path/to/cold-data/local-file -blocks
Expected checks: listPolicies should include RS-6-3-1024k. getPolicy should return that policy name for the directory. The fsck output should show striped blocks with multiple internal block identifiers per stripe, rather than the simple replicated block list you would see for a standard file.
To gauge the read cost, copy a replicated file and an EC file of similar size into separate directories and time a full read with hdfs dfs -cat. Do not expect identical latency; the EC read will typically be slower because of reconstruction. If the difference is unacceptable for your access pattern, keep the data replicated.
Limitations and operational gotchas
Changing an EC policy does not retroactively convert already-written blocks. It only affects files created after the policy is set. If you have an existing cold dataset stored with replication, moving it to EC requires a rewrite or a tool like distcp to a new EC-enabled directory. If you need to revert, set the directory policy back to a replication policy; existing EC files remain EC until rewritten.
EC files are represented as striped blocks with multiple internal cells, which affects NameNode metadata accounting and block reporting. Monitor NameNode heap and block counts after conversion, especially on large directories.
Decommissioning and rebalancing behavior under EC can differ from replication because reconstruction traffic is higher. Validate these operations under your specific Hadoop distribution before adopting EC at scale. Distribution vendors sometimes ship stability flags or default cell sizes that differ from Apache Hadoop upstream, so review your release notes for version-specific limitations.
An actionable decision framework
Use EC when your data is cold, immutable, and read occasionally. Keep replication when your workload is hot, latency-sensitive, or append-heavy. If you decide to try EC, start with a single non-critical directory. Apply the policy, write a file, verify the striped layout with fsck, and compare read latency against a replicated control. Then simulate a DataNode failure or decommission and watch reconstruction time and network traffic through the NameNode web UI and DataNode logs.
Because EC behavior and defaults vary across Hadoop distributions and minor versions, confirm the exact policy names, cell sizes, and stability flags in your distribution's documentation before production rollout. If those checks pass, you can cut cold-data storage overhead in half without gambling on an unsupported feature.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.