Distributed Storage Architectures & Parallel Processing
An authoritative reference manual on Hadoop Distributed File System (HDFS) internals, master-worker metadata management, cluster scaling, cloud delivery models, MapReduce execution flow, and architectural design patterns.
2.1 Distributed Storage Mechanics & HDFS Overview
Single-machine file systems (e.g. Windows NTFS, Linux ext4, macOS APFS) index files using localized OS inode structures pointing to small disk blocks (typically 4 KB). When dataset sizes scale into multi-terabytes, single-machine file systems hit strict physical capacity boundaries and present a Single Point of Failure (SPOF).
To solve this, Google published the *Google File System (GFS)* paper in 2003, which inspired **Apache HDFS (Hadoop Distributed File System)**. HDFS partitions large files into large fixed-size blocks (typically 128 MB) and distributes them across a cluster of commodity server nodes.
HDFS is a distributed, fault-tolerant, block-structured file system designed to run on commodity hardware. It provides streaming access to large files, optimized for sequential disk I/O reads under a "Write-Once, Read-Many" (WORM) access pattern.
Single Machine File System: Storing 1,000 books in one office cabinet. If the cabinet overflows, you cannot add books. If the office catches fire, all books are lost.
Distributed File System (HDFS): Splitting books into 128-page chapters, making 3 identical photocopies of every chapter, and storing them across 50 houses in different neighborhoods.
- A central Manager (NameNode) holds a catalog map showing which neighbor holds which chapter.
- If Neighbor A's house burns down, no data is lost because Neighbors B and C still hold identical backup copies!
2.2 HDFS Component Architecture & Placement Mechanics
graph TD
Client[Client Application] -->|1. Request file read/write metadata| NN[NameNode - Master Metadata Manager]
NN -->|2. Returns DataNode mapping & block locations| Client
Client -->|3. Writes Block 1| DN1[DataNode 1 - Server Rack 1]
DN1 -.->|4. Pipeline Replication: Replica 2| DN2[DataNode 2 - Server Rack 1]
DN2 -.->|5. Pipeline Replication: Replica 3| DN3[DataNode 3 - Server Rack 2]
subgraph Cluster Consensus & Monitoring
DN1 -->|Heartbeat every 3s + Block Report| NN
DN2 -->|Heartbeat every 3s + Block Report| NN
DN3 -->|Heartbeat every 3s + Block Report| NN
end
| HDFS Architectural Element | Technical Specification & Role | High Availability & Fault Tolerance |
|---|---|---|
| NameNode (Master Node) | Manages the file system namespace, directory hierarchy, permissions, and block location mapping. Holds all metadata in server RAM. | Persists metadata snapshots in **FSImage** and logs changes in **EditLog**. Synchronized with a Standby NameNode via ZooKeeper. |
| DataNode (Worker Node) | Physical computer nodes storing raw 128 MB file blocks on local hard drives. Executes read/write operations from clients. | Transmits **Heartbeat signals (every 3 seconds)** to NameNode. If no signal arrives for 10 minutes, NameNode re-replicates blocks. |
| Data Block (128 MB) | Large fixed-size storage chunk e.g. a 1 GB input file is divided into 8 blocks of 128 MB. | Large block sizes minimize NameNode RAM overhead and optimize continuous sequential disk throughput. |
| Rack Awareness Policy | Block placement rule: Copy 1 $\rightarrow$ Local Node (Rack 1); Copy 2 $\rightarrow$ Remote Node (Rack 1); Copy 3 $\rightarrow$ Remote Node (Rack 2). | Guarantees data survival even if an entire physical server rack loses power or suffers network switch failure. |
2.3 Cluster Scaling Paradigms & Cloud Integration
graph LR
subgraph Vertical Scaling - Scale Up
A[Single Server: 16 GB RAM] -->|Replace hardware| B[Mainframe: 512 GB RAM]
B -->|Hardware Ceiling Limit| C[Exponential Cost & Single Point of Failure]
end
subgraph Horizontal Scaling - Scale Out
D[Commodity Node 1] -->|Network Switch| E[Commodity Node 2]
E -->|Network Switch| F[1,000 Commodity Nodes]
F -->|Linear Scalability| G[Predictable Cost & High Availability]
end
| Comparison Axis | Vertical Scaling (Scale-Up) | Horizontal Scaling (Scale-Out) 🏆 |
|---|---|---|
| Hardware Strategy | Upgrade existing server hardware (add faster CPU cores, more RAM, SSDs). | Link standard commodity servers together over a network cluster. |
| Cost Trajectory | Exponential. Enterprise multi-terabyte RAM servers cost hundreds of thousands of dollars. | Linear. Add standard $1,000 server nodes as data volume grows. |
| Maximum Limit | Strict physical limit enforced by single motherboard architecture. | Virtually unlimited. Tech enterprises manage clusters of over 50,000 linked nodes! |
| Fault Tolerance | Low. If the single super-server crashes, the entire system drops offline (SPOF). | High. If 10 servers crash out of a 1,000-node cluster, the remaining 990 nodes continue operating. |
Cloud Delivery Models for Big Data
- IaaS (Infrastructure as a Service): Provisioning raw virtual machines, virtual networks, and block storage e.g. AWS EC2, Google Compute Engine.
- PaaS (Platform as a Service): Managed compute platforms where developers deploy jobs without OS administration e.g. AWS EMR, Google Dataproc.
- SaaS (Software as a Service): Fully managed analytical applications accessed via web APIs e.g. Snowflake, Google BigQuery.
2.4 Parallel Compute Pipelines & MapReduce Mechanics
The **MapReduce model** processes multi-terabyte datasets stored on HDFS across two core execution phases: **Map** and **Reduce**.
graph TD
InputData[1 TB Input File on HDFS] --> Splitting[Split into 128 MB Chunks]
subgraph Map Execution Phase
Splitting --> Mapper1[Mapper 1: Parse Local Block 1]
Splitting --> Mapper2[Mapper 2: Parse Local Block 2]
Splitting --> Mapper3[Mapper 3: Parse Local Block 3]
end
subgraph Shuffle & Sort Network Transport Phase
Mapper1 --> Partitioner[Partitioner Engine: Route Keys via Hash Modulo]
Mapper2 --> Partitioner
Mapper3 --> Partitioner
end
subgraph Reduce Execution Phase
Partitioner --> Reducer1[Reducer 1: Aggregate Keys 'A-M']
Partitioner --> Reducer2[Reducer 2: Aggregate Keys 'N-Z']
end
Reducer1 --> HDFSOut[Write final summary files to HDFS]
Reducer2 --> HDFSOut
- Input Splitting: Input files are divided into 128 MB blocks.
- Map Phase: Mapper nodes process local blocks in parallel ("Data Locality"), parsing lines and emitting key-value pairs e.g. `(word, 1)`.
- Shuffle & Sort Phase: The framework sorts intermediate pairs and routes matching keys across the network to the same Reducer worker.
- Reduce Phase: Reducers combine values for each unique key e.g. `(word, [1, 1...]) -> (word, N)`, writing output files back to HDFS.
2.5 Architecture Patterns: Lambda vs. Kappa
| Architecture Metric | Lambda Architecture (Dual Path) | Kappa Architecture (Single Path Stream) ⚡ |
|---|---|---|
| Core Design Concept | Combines a **Batch Layer** (slow, precise historical compute) with a **Speed Layer** (fast, real-time streaming). | Eliminates the Batch Layer completely! Treats all historical and live data as a single continuous **Data Stream**. |
| Codebase Maintenance | Higher complexity. Requires maintaining two separate codebases e.g. Spark for batch and Flink for streaming. | Lower complexity. Single unified stream processing codebase e.g. Apache Flink or Kafka Streams. |
| Data Reprocessing | Re-runs batch jobs across raw historical files stored in HDFS/S3. | Replays raw log streams from Apache Kafka starting from an earlier timestamp offset. |
✍️ Chapter 2 Reference Exercises & Review Problems
- Definition: Data Locality refers to assigning Mapper tasks to execute directly on the physical DataNode server that houses the target 128 MB block on its local disk.
- Throughput Advantage: Transferring massive files across network switches creates network congestion. Moving lightweight compiled code (a few KB) to the data avoids network transfer, maximizing I/O performance.
- Placement Policy:
1. Replica 1 is stored on a DataNode in the local rack (Rack 1).
2. Replica 2 is stored on a different DataNode in the same rack (Rack 1).
3. Replica 3 is stored on a DataNode in a separate physical rack (Rack 2).
- Protection: Protects against individual node disk failures (via Replica 1 & 2) and complete physical rack failures e.g. rack power loss or top-of-rack network switch failure (via Replica 3).