Skip to main content

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:
Key Concepts:
  1. Block Pool: Each NameNode manages its own block pool
    • Blocks from different namespaces don’t mix
    • Each block has namespace ID prefix
  2. Namespace Volume: Namespace + Block Pool = one unit
    • Independent namespaces
    • No coordination between NameNodes needed
  3. ViewFS: Client-side mount table to access federated cluster

Configuration

hdfs-site.xml (NameNode 1):
ViewFS Mount Table (core-site.xml on clients):
Client Access:

HDFS High Availability (HA)

Standby NameNode Architecture

Quorum Journal Manager (QJM)

How It Works:
  1. 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
  2. Standby NameNode tails edit logs
    • Reads from JournalNodes continuously
    • Applies edits to its in-memory state
    • Always ready to take over
  3. Failover Process:

HA Configuration

hdfs-site.xml:
Manual Failover:

Erasure Coding

The Space Efficiency Problem

Traditional Replication:
Erasure Coding Alternative:

How Erasure Coding Works

Reed-Solomon (RS) Encoding:

Erasure Coding Policies

Built-in Policies:

Configuration and Usage

Enable Erasure Coding:
When to Use Erasure Coding: Good for:
  • Archive/cold data (rarely accessed)
  • Large files (>100MB)
  • Write-once, read-many workloads
  • Cost-sensitive storage
Not ideal for:
  • Hot data (frequently accessed)
  • Small files (<10MB)
  • Data requiring low-latency reads
  • High write throughput workloads
Performance Considerations:

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:
Snapshot Diff:

Use Cases

1. Backup and Recovery:
2. Testing and Validation:
3. Compliance and Auditing:

HDFS Caching

Centralized Cache Management

Problem: Hot data read repeatedly from disk Solution: Cache frequently accessed blocks in DataNode memory

Cache Pool and Directive Management

Create Cache Pool:
Add Cache Directive:
Programmatic Caching:

HDFS Performance Tuning

Short-Circuit Local Reads

Enable reading from local DataNode without network:
Performance Impact: 30-50% faster for local reads

Hedged Reads

Read from multiple replicas simultaneously for tail latency:
How It Works:

DataNode Configuration


Monitoring and Metrics

JMX Metrics Exposure

NameNode Metrics:
Programmatic Monitoring:

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:
  1. “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
  2. “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
  3. “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