Advanced HDFS Features
Module Duration: 3-4 hours
Focus: Enterprise HDFS features for production scale
Prerequisites: HDFS Architecture basics from Module 2
HDFS Federation
The Scalability Problem
Traditional HDFS Limitation:Federation Architecture
Multiple independent NameNodes sharing the same DataNode pool:-
Block Pool: Each NameNode manages its own block pool
- Blocks from different namespaces don’t mix
- Each block has namespace ID prefix
-
Namespace Volume: Namespace + Block Pool = one unit
- Independent namespaces
- No coordination between NameNodes needed
- ViewFS: Client-side mount table to access federated cluster
Configuration
hdfs-site.xml (NameNode 1):HDFS High Availability (HA)
Standby NameNode Architecture
Quorum Journal Manager (QJM)
How It Works:-
Active NameNode writes edit logs to JournalNodes
- Writes to quorum (majority) of JournalNodes
- For 3 JNs: needs 2 successful writes
- For 5 JNs: needs 3 successful writes
-
Standby NameNode tails edit logs
- Reads from JournalNodes continuously
- Applies edits to its in-memory state
- Always ready to take over
-
Failover Process:
HA Configuration
hdfs-site.xml:Erasure Coding
The Space Efficiency Problem
Traditional Replication:How Erasure Coding Works
Reed-Solomon (RS) Encoding:Erasure Coding Policies
Built-in Policies:Configuration and Usage
Enable Erasure Coding:- Archive/cold data (rarely accessed)
- Large files (>100MB)
- Write-once, read-many workloads
- Cost-sensitive storage
- Hot data (frequently accessed)
- Small files (<10MB)
- Data requiring low-latency reads
- High write throughput workloads
HDFS Snapshots
Snapshot Basics
Snapshots provide point-in-time, read-only copies of directories:Copy-on-Write Mechanism
How Snapshots Save Space:Snapshot Operations
Enable Snapshots:Use Cases
1. Backup and Recovery:HDFS Caching
Centralized Cache Management
Problem: Hot data read repeatedly from disk Solution: Cache frequently accessed blocks in DataNode memoryCache Pool and Directive Management
Create Cache Pool:HDFS Performance Tuning
Short-Circuit Local Reads
Enable reading from local DataNode without network:Hedged Reads
Read from multiple replicas simultaneously for tail latency:DataNode Configuration
Monitoring and Metrics
JMX Metrics Exposure
NameNode Metrics:Best Practices Summary
Use Federation for Scale
When metadata exceeds 100M files or single NameNode RAM limits, deploy federation to horizontally scale.
HA is Mandatory
Always use HA in production. Manual NameNode recovery takes hours and risks data inconsistency.
Erasure Code Cold Data
Archive data older than 90 days with erasure coding to save 50% storage costs.
Snapshot for Safety
Daily snapshots before risky operations. Retention: 7 daily, 4 weekly, 12 monthly.
Interview Focus
Common Questions:-
“How does HDFS HA prevent split-brain?”
- Fencing: Active NN cannot write to JournalNodes after losing quorum
- ZooKeeper coordination ensures only one Active NN at a time
- SSH fencing kills old NN process if needed
-
“When to use Federation vs HA?”
- HA: High availability, failover (same namespace)
- Federation: Horizontal scalability (multiple independent namespaces)
- Can combine both: Federated cluster with HA for each namespace
-
“Why is erasure coding slower than replication?”
- Must read from 6+ DataNodes vs 1 for replication
- Decode overhead for reconstructing data
- Trade-off: 50% storage savings for slightly slower reads
What’s Next?
Module 3: MapReduce Programming Model
Now that you master storage, learn to process data with MapReduce