MapReduce and GFS
Introduction r To understand Google’s file system let us look at the sort of processing that needs to be done r We will look at MapReduce
Motivation r Google needed a good distributed file system m Redundant storage of massive amounts of data on cheap and unreliable computers r Why not use an existing file system? m Google’s problems are different from anyone else’s Different workload and design priorities m GFS is designed for Google apps and workloads m Google apps are designed for GFS
Google Workload Characteristics r Most files are mutated by appending new data – large sequential writes r Random writes are very uncommon r Files are written once, then they are only read r Reads are sequential r Large streaming reads and small random reads r High sustained throughput favoured over low latency
Google Workload Characteristics r Google applications: m Data analysis programs that scan through data repositories m Data streaming applications m Archiving m Applications producing (intermediate) search results
Assumptions r High component failure rates m Inexpensive commodity components fail all the time r “Modest” number of HUGE files m Just a few million m Each is 100MB or larger; multi-GB files typical
GFS Design Decisions r Files stored as chunks m Fixed size (64MB) r Single master to coordinate access, keep metadata m Simple centralized management r Application Programming Interface is different then that found for NFS
GFS Architecture r Single master for a cluster r Multiple chunkservers
Chunks r Files are divided into fixed-size chunks r Each chunk has an identifier, chunk handle, assigned by the master at the time of chunk creation r Each chunk is replicated 3 times r Chunk size is fixed size (64MB)
Chunkservers r Store chunks on local disks as Linux files r Read/write chunk data specified by a chunk handle and byte range
Master r Stores metadata m The file and chunk namespaces m Mapping from files to chunks m Locations of each chunk’s replicas (referred to as chunk locations) r Interacts with clients r Creates chunk replicas
Master r Orchestrates chunk modifications across multiple replicas m Ensures atomic concurrent appends m Locks concurrent operations r Deletes old files (via garbage collection)
Interactions r Assume a read r The client translates the file name and byte offset specified application into a chunk index within the file r The master replies with the corresponding chunk handle (information needed to find a chunk) and locations of the replicas. r The client then sends a request to one of the replicas most likely the closest one r Note: Further reads of the same chunk require no more client-master interaction
Chunk Size r Chunk size is 64 MB m Larger than typical file system block sizes r Advantages m Reduces a client’s need to interact with the master m Reduce network overhead by keeping a persistent TCP connection to the chunkserver over a period of time m Reduces the size of the metadata stored on the master
Chunk Size r Disadvantages m A small file consists of a small number of chunks m The chunkservers storing these chunks may become hot spots if many clients are accessing the same file Does not occur very much in practice
Metadata On Master r Metadata – Information about the data: m File names m Mapping of file names to chunk IDs m Chunk locations r Metadata is kept in memory r File names and chunk mappings are also kept persistent in an operation log r Chunk locations are kept in memory only m It will be lost during the crash m The master asks chunk servers about their chunks at startup – builds a table of chunk locations
Why Keep Metadata In Memory? r To keep master operations fast r Master can periodically scan its internal state in the background, in order to implement: m Re-replication (in case of chunk server failures) m Chunk migration (for load balancing)
Why Not Keep Chunk Locations Persistent? r Chunk location – which chunk server has a replica of a given chunk r Master polls chunk servers for that information on startup r Thereafter, master keeps itself up-to- date: m It controls all initial chunk placement, migration and re-replication m It monitors chunkserver status with regular HeartBeat messages
Why Not Keep Chunk Locations Persistent? r Motivation: simplicity r Eliminates the need to keep master and chunkservers synchronized r Synchronization would be needed when chunkservers: m Join and leave the cluster m Change names m Fail and restart
Operation Log r Historical record of metadata changes r Maintains logical order of concurrent operations r Log is used for recovery – the master replays it in the event of failures r Master periodically checkpoints the log
Updates of Replicated Data r Each mutation (modification) is performed at all the replicas r Modifications are applied in the same order across all replicas r For each chunk there is a primary chunk r The primary picks a serial order for all mutations to the chunk r The client pushes data to all replicas r The primary tells the replicas in which order they should apply modifications
Updates of Replicated Data (cont.) 1. Client asks master for replica locations 2. Master responds 3. Client pushes data to all replicas; replicas store it in a buffer cache 4. Client sends a write request to the primary (identifying the data that had been pushed) 5. Primary forwards request to the secondaries (identifies the order) 6. The secondaries respond to the primary 7. The primary responds to the client
Failure Handling During Updates r If a write fails at the primary: m The primary may report failure to the client – the client will retry m If the primary does not respond, the client retries from Step 1 by contacting the master r If a write succeeds at the primary, but fails at several replicas m The client retries several times (Step 3-7)
Atomic Record Appends r Atomic append is a write – but GFS (the primary replica) chooses the offset where the append happens r This way GFS can decide on serial order of concurrent appends without client synchronization r Useful when there are a lot file appends from multiple clients and it doesn’t matter in what order the appends are done
Atomic Record Appends r The client pushes the data (a record) to all replicas of the last chunk of the file r Sends request to primary r Case 1: Record fits within the maximum size of chunk m Primary appends data to its replica m Primary tells the secondaries to write the data at the exact offset
Atomic Record Appends r Case 2: What if appending the record would cause the chunk to exceed the maximum size m Pad the chunk to the maximum size m Tell the primaries to do the same thing m Reply to client indicating that the operation should be retried on the next chunk
Deployment in Google r Many GFS clusters r Hundreds/thousands of storage nodes each r Managing petabytes of data
Summary r GFS demonstrates how to support large- scale processing workloads on commodity hardware m design to tolerate frequent component failures m optimize for huge files that are mostly appended and read m feel free to relax and extend FS interface as required m go for simple solutions (e.g., single master) r GFS has met Google’s storage needs