Cloud & Infrastructure · Paper 01 / 05

The Google File System

Sanjay Ghemawat, Howard Gobioff, Shun-Tak Leung

2003 · SOSP · ~12 min read

Read the original paper

When you run thousands of cheap disks, some are always broken. GFS was designed around that fact, and taught the industry to store files by expecting failure.

The problem: when something is always broken

File systems of 2003 assumed that disks mostly worked, that files were modest, and that programs read and wrote them in small pieces at random. Google’s machines broke every one of those assumptions. It ran thousands of cheap PCs with commodity disks, so at any moment some were dead and some were quietly corrupting data. Its files were web crawls measured in gigabytes and terabytes, written once by a stream of appends and read in long sequential sweeps by programs like MapReduce. A file system built for a workstation, scaled up, would spend its life fighting the hardware and the workload at once.

So the authors wrote down their assumptions first, which is why the paper is still worth reading as a method even where its design has been superseded: failure is normal; files are huge; appends dominate; bandwidth matters more than latency; and the file system and the applications are built by the same company, so the interface can be bent to fit.

The idea: one master for the map, many servers for the bytes

A GFS cluster has a single master and many chunkservers. Files are cut into fixed 64-megabyte chunks, each stored on three chunkservers. The master keeps all metadata in memory: the file namespace, which chunks make up each file, and where every chunk’s replicas are. Clients ask the master where a chunk lives, cache the answer, and then read or write the bytes directly from chunkservers. The master handles a few bytes per operation; the terabytes never pass through it.

clientmasterchunkserver 1chunkserver 2chunkserver 3① file, chunk index② chunk handle + 3 locations (cached)③ read 64 MB directlythe master touches bytes of metadata per operation, never the data
A read. Metadata from the master, cached; data straight from a chunkserver. Keeping the master off the data path is what lets one machine coordinate thousands.

How it works

The master expects to lose chunkservers and treats a missing replica as ordinary work. It exchanges heartbeats with every server, and when one goes silent the chunks it held become under-replicated and are cloned elsewhere, most urgent first; when the server returns, its stale copies are garbage-collected lazily. Chunkservers checksum every 64-kilobyte block, so a disk that lies is caught before its data spreads. The master’s own state is protected by an operation log replicated to other machines and by periodic checkpoints; if it dies, a new master replays the log and asks the chunkservers what they hold.

Try itLose a chunkserver, keep the file

A file is a list of 64 MB chunks; each chunk lives on three chunkservers. The master only knows where things are.

master · metadatachunk 1 → CS1 CS2 CS3chunk 2 → CS3 CS4 CS5chunk 3 → CS5 CS1 CS2chunk 4 → CS2 CS3 CS4CS1chunk 1chunk 3CS2chunk 1chunk 3chunk 4CS3chunk 1chunk 2chunk 4CS4chunk 2chunk 4CS5chunk 2chunk 3
chunks4× 3 copies
under-replicated0every chunk has three live copies
servers up5of 5
The master holds only metadata: file → chunks → which servers. Clients never stream data through it.

Failure is not an exception here, it is the steady state: the master expects servers to vanish and treats a missing replica as routine work. Because clients fetch data directly from chunkservers, a single master can coordinate thousands of them without becoming the bottleneck.

Writes separate data from control. The client pushes the bytes along a chain of replicas, each forwarding to the next nearest, so every network link is used once. Then it asks the primary replica, which holds a short lease from the master, to apply the write; the primary chooses a serial order and tells the others to apply it in that order. One machine decides, briefly and locally, and no global coordination is needed.

clientreplica Aprimary · leasereplica Cdata: pushed to the nearest replica, forwardedalong the chain, buffered, not yet appliedcontrol: “write it” goes to the primary only;it picks a serial order and tells the othersnetwork bandwidth is used once per hop; one machine decides the order
A write. Bytes are pipelined along a chain (each hop uses full bandwidth); the order is decided by the primary replica, which holds the lease for that chunk.

The interface is bent in one famous place. Record append lets many clients append to one file concurrently with GFS choosing the offset, guaranteeing that each record lands at least once, somewhere, atomically, possibly with duplicates or padding between records. That is a weaker promise than a POSIX file makes and a much stronger one than Google’s producer-consumer pipelines needed; applications tolerated duplicates with sequence numbers and checksums, and the file system stayed fast.

What it changed

GFS was the floor under MapReduce and Bigtable, and its open-source copy, the Hadoop Distributed File System, was the floor under the big-data industry: the NameNode and DataNodes are the master and chunkservers under other names. Inside Google it was replaced by Colossus around 2010, which spread the metadata across many machines and used erasure coding instead of three copies, because the single master finally did become the limit. What survived is the posture: design for failure as the normal case, replicate at the file-system layer so applications need not, and keep the metadata path and the data path apart.

Where you meet it today

  • HDFS and every Hadoop-era cluster; the NameNode is still the single master.
  • Object stores. S3 and its peers keep the separation of a metadata service from storage nodes, with erasure coding where GFS used replication.
  • Chunking. Splitting large objects into fixed-size, independently replicated pieces is now how backups, video and ML datasets are stored.
  • Leases. A short-lived grant of authority from a coordinator, renewed by heartbeat, is the standard way to pick a primary without consensus on every write.