Google File System
Consistency Model
GFS
Data Management
Distributed Computing

Google File System Consistency Model

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Google File System (GFS) is a scalable distributed file system designed by Google to efficiently distribute large data across multiple machines. An essential aspect of GFS is its consistency model, which differs from traditional file systems due to its distributed nature.

GFS Consistency Model

In the context of GFS, consistency refers to how updates (writes or appends) to a file are propagated and made visible to processes reading the file. The consistency model of GFS is primarily defined by its robustness and performance under high demand where multiple client operations may not always see the same data at the same time.

Guarantees Provided by GFS

GFS provides the following consistency guarantees:

  1. Consistency: After the completion of a mutation (e.g., write or append operation), GFS guarantees that all subsequent data accesses will see the effects of the mutation. This is referred to as "convergence consistency".
  2. Atomicity: Modifications are atomic at the chunk level, meaning they either succeed completely or fail; they do not leave partial data.

Modes of File Modification

GFS categorizes file modifications into two types:

  • Writes: Overwrite data at a specified position
  • Appends: Add data to the end of the file, managed by GFS to avoid conflicts

Challenges in Consistency

Due to its distributed nature, ensuring consistency across all nodes in GFS involves dealing with challenges such as network latency, hardware failures, and concurrent modifications. GFS handles these challenges using:

  • Master and Chunk Servers: The master server manages metadata and operations across chunk servers, which store the actual chunks (pieces) of data.
  • Lease and Mutation Order: The master grants a lease to one of the replicas (primary) to maintain a mutation order, which all replicas follow.

How GFS Achieves Consistency

  1. Write and Append Operations: When a client writes or appends, it first communicates with the master to find the responsible chunk servers. For writes, the client pushes the data to all replicas. The primary chunk, which has the lease, then sequences this mutation with any concurrent ones before all replicas follow.
  2. Record Append: This operation is special in GFS, helping to avoid the complexities of concurrent appends and keeping the system efficient by managing the data placement and replication handling.

Handling Failures and Replica Inconsistencies

In the event of server failures or network issues, GFS uses techniques like replication and recovery. Periodic scanning and comparison among chunks ensure that the replicas are consistent. If discrepancies are found, GFS reconciles the inconsistencies by reapplying the correct data from the primary to the replicas.

Implementation Example

Consider a scenario where multiple clients are appending data to a log file:

  1. Client obtains current chunkservers: The master directs the client to the replicas holding the last chunk.
  2. Client pushes data to replicas: The data is pushed to all replicas.
  3. Primary orders the operations: The primary, designated by the master, orders the append operation.
  4. Data is replicated: All replicas confirm back to the client post-success.

Summary Table

Here is a quick reference summary of key points related to the GFS consistency model:

AspectDetails
Consistency typeConvergence consistency after mutations complete
AtomicityMutations are atomic at the chunk level
Operations managedWrites, appends, record appends
Failure handlingReplications, periodic consistency checks, recovery systems
System componentsMaster server, chunk servers (replicas), clients

Conclusion

By managing consistency through a well-defined model handling atomicity, ordering, and replication, GFS ensures reliability and efficient performance even in large distributed environments. GFS's approach addresses the specific needs of managing enormous amounts of data while providing quick access and strong consistency guarantees.


Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.