Chapter 2: Architecture Overview
The Google File System architecture is elegantly simple: a single master coordinating hundreds of chunkservers, with clients communicating directly with chunkservers for data operations. This separation of control plane (metadata on the master) from data plane (actual bytes on chunkservers) is one of GFS’s most important contributions to distributed systems design. The same pattern appears today in HDFS (NameNode vs DataNode), Kubernetes (API server vs kubelets), and virtually every modern cloud storage service. This chapter explores how these components work together to create a highly scalable distributed file system.- Understand the three main components: Master, Chunkservers, and Clients
- Learn how data flows through the system
- Grasp the separation of control and data flow
- Appreciate the single-master design choice
System Components
GFS consists of three main types of components:The Master
The master is the brain of GFS — a single process that manages all metadata. At first glance, a single master looks like an obvious bottleneck and single point of failure. Skeptics in 2003 criticized this choice heavily. But the GFS team recognized a crucial insight: by keeping the master entirely out of the data path and minimizing its per-operation cost, a single machine could handle metadata for a petabyte-scale cluster. The design leverages Metadata Minimization (64 bytes per chunk, all in RAM) and Direct Data Transfer (clients talk to chunkservers for data, never routing bytes through the master) to ensure it can manage petabytes of data from thousands of clients. This “simple master, smart clients” model proved so effective that it became the default architecture for an entire generation of distributed systems.- Namespace & Locking
- Lease Mechanism
- In-Memory State
/a/b/c don’t require locking the parent /a or /a/b. Instead:- To create
/home/user/foo, the master acquires Read Locks on/homeand/home/user, and a Write Lock on/home/user/foo. - This allows concurrent file creations in the same directory (e.g.,
/home/user/barcan be created simultaneously as it only needs a read lock on the parent). - No deadlock risk: Locks are acquired in a consistent lexicographical order.
dentry locking.- Persistent State
- Why Single Master?
Chunkservers
Chunkservers are the workhorses that store actual data:Storage Model
- Each chunk: 64MB max
- Stored as Linux file on local disk
- Named by chunk handle (globally unique)
- File path:
/gfs/chunks/<chunk_handle> - Checksums for each 64KB block
- Multiple chunks per disk
Responsibilities
- Store and retrieve chunks
- Verify data integrity (checksums)
- Replicate chunks to other servers
- Report to master via heartbeat
- Delete garbage chunks
- Handle client read/write requests
No Metadata Cache
- Chunkservers don’t cache metadata
- Don’t track which files chunks belong to
- Master tells them what to do
- Simplifies consistency
- Reduces memory requirements
Replication
- Each chunk replicated 3x (default)
- Replicas on different racks
- Replicas can serve reads
- One primary for writes (leased)
- Replicas forward writes in chain
Clients
GFS clients are library code linked into applications:Data Flow Patterns
Understanding how data flows through GFS is crucial. The key principle is the Separation of Control Flow and Data Flow. Control flows from client to master and then to the primary, while data is pushed linearly along a chain of chunkservers to maximize network throughput. This separation is one of the most practically important ideas in the paper. By decoupling “where should I write?” (control) from “here is the actual data” (data), GFS ensures the master never becomes a bandwidth bottleneck. Modern systems like Apache Kafka use the same principle: the controller handles partition assignments and leader election, but producers and consumers transfer data directly to/from broker nodes.The Pipeline Push Mechanism
To fully utilize each machine’s network bandwidth, data is pushed along a chain of chunkservers rather than in a star topology.Read Operation
Client Requests Metadata
Client Contacts Chunkserver
Data Validation
Write Operation
Writes are more complex due to maintaining consistency across replicas:Record Append Operation
The record append is GFS’s “killer feature”:- How It Works
- Detailed Flow
- Consistency Guarantees
- Application Usage
Architecture Deep Dive
Chunk Size: Why 64MB?
The 64MB chunk size is a defining characteristic of GFS:Advantages of Large Chunks
Advantages of Large Chunks
-
Reduced Metadata:
-
Fewer Network Hops:
- Client requests chunk locations once
- Works with chunk for extended period
- Reduces master load significantly
-
Better TCP Performance:
- Long-lived TCP connections
- Connection setup cost amortized
- Better throughput utilization
-
Data Locality:
- MapReduce can schedule entire chunk to one worker
- Reduces network transfer
- Better cache utilization
Disadvantages and Mitigations
Disadvantages and Mitigations
-
Internal Fragmentation:
-
Hot Spots:
-
Startup Issues:
- Small configuration files
- Many clients read at startup
- Temporary hotspot
Metadata Design
- In-Memory Only
- What's Persistent
- Checkpointing
Consistency Without Locks
GFS achieves consistency without distributed locking:Component Interactions
Master-Chunkserver Communication
Client-Master Communication
Key Architectural Decisions
Single Master
- Simplifies design dramatically
- Strong metadata consistency
- Global knowledge for decisions
- Fast in-memory operations
- Minimize master involvement
- Shadow masters for HA
- Client caching
Large Chunks
- Reduces metadata size
- Fewer network round trips
- Better throughput
- Data locality benefits
- Internal fragmentation
- Potential hot spots
- Not optimal for small files
Separation of Control/Data
- Master not bottleneck for data
- Scales to GB/s throughput
- Parallel data transfers
- Flexible data flow routing
- Master handles 1000s ops/sec
- Data path limited only by network
Relaxed Consistency
- Higher performance
- Simpler implementation
- No distributed transactions
- Matches application needs
- Application-level handling
- Deduplication
- Validation
Interview Questions
Basic: What are the main components of GFS?
Basic: What are the main components of GFS?
-
Master (single):
- Stores all metadata in RAM
- Manages namespace (files/directories)
- Tracks chunk locations
- Makes placement decisions
- Coordinates system-wide operations
-
Chunkservers (hundreds/thousands):
- Store 64MB chunks as Linux files
- Serve read/write requests
- Replicate data to other chunkservers
- Report status to master via heartbeat
-
Clients (many):
- Application library
- Caches metadata
- Communicates with master for metadata
- Talks directly to chunkservers for data
Intermediate: How does GFS separate control and data flow?
Intermediate: How does GFS separate control and data flow?
- Client asks master for chunk locations
- Master returns list of replicas
- Client caches this information
- Happens only once per chunk/file
- Client communicates directly with chunkservers
- No master involvement for data transfer
- Enables massive parallel throughput
- Master not a bottleneck
- Master handles thousands of metadata ops/sec
- Data throughput limited only by network/chunkservers
- System scales to hundreds of clients at GB/s aggregate
Advanced: Explain the write data flow in detail
Advanced: Explain the write data flow in detail
- Client asks master for chunk replicas
- Master grants lease to one replica (primary)
- Client caches primary and secondary locations
- Client pushes data to closest replica
- Each replica forwards to next in chain
- Pipelined: forward while receiving
- All replicas ACK when data buffered in memory
- Data not yet written to disk!
- Client sends write command to primary
- Primary assigns serial number (ordering)
- Primary applies writes to local disk in order
- Primary forwards write order to secondaries
- Secondaries apply in same order
- Secondaries ACK to primary
- Primary ACKs success/failure to client
- Data flow optimized for network topology
- Control flow ensures consistent ordering
- Primary serializes concurrent operations
- No distributed consensus needed
- If any replica fails, entire write fails (client retries)
System Design: Why is chunk location not persisted?
System Design: Why is chunk location not persisted?
-
Chunkservers are source of truth:
- Chunkserver knows what chunks it has (on disk)
- No risk of inconsistency between master and reality
-
Dynamic nature:
- Chunks added/deleted frequently
- Chunkservers may fail
- Disks may fail
- Replication changes chunk locations
-
Simpler consistency:
- No need to keep persistent state in sync
- No risk of master having stale information
- Master polls chunkservers to rebuild state
- Startup: Master polls all chunkservers for chunk list
- Ongoing: Heartbeat messages update chunk locations
- Changes: Chunkservers report additions/deletions
- Eliminates entire class of consistency bugs
- Faster recovery (no persistent state to reload)
- Simpler implementation
- Startup requires polling all chunkservers
- Acceptable because happens rarely and completes quickly
Summary
- Single Master Design: Simplicity and strong consistency for metadata
- Separation of Concerns: Control (master) vs. Data (chunkservers) flow
- Large Chunks: 64MB chunks reduce metadata and network overhead
- In-Memory Metadata: Fast operations, simple design
- Leases for Consistency: Primary replica orders operations without consensus
- Direct Client-Chunkserver: Data flow doesn’t involve master
- Relaxed Consistency: Trade-off for performance, application handles edge cases
- Record Append: Atomic concurrent appends without locks
Up Next
In Chapter 3: Master Operations, we’ll explore:- Namespace management and locking
- Chunk creation and allocation
- Replica placement strategies
- Lease management in detail
- Garbage collection mechanism
Interview Deep-Dive
Explain GFS lease mechanism to me. Why leases instead of distributed locks or a consensus protocol?
Explain GFS lease mechanism to me. Why leases instead of distributed locks or a consensus protocol?
The GFS master stores all metadata in RAM. What are the operational risks, and how would you mitigate them?
The GFS master stores all metadata in RAM. What are the operational risks, and how would you mitigate them?
How does GFS separate control flow from data flow, and why is this separation so important?
How does GFS separate control flow from data flow, and why is this separation so important?