---
title: "GFS master role in read/write"
subject: "Big Data Technologies"
chapter: 2
key: "semester_8/big_data_technologies:gfs-master-read-write-flow"
source: https://www.bctengineer.com/q/semester_8/big_data_technologies/gfs-master-read-write-flow
site: BCT Engineering
---

# GFS master role in read/write

Big Data Technologies · Chapter 2: Google File System

- Asked in: 2075 Bhadra, 10 marks
- Video: [Google File System in 6 mins](https://www.youtube.com/watch?v=OgWrw9dQ9CM) — learnTechWithPriya
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_8/big_data_technologies/gfs-master-read-write-flow
- Whole chapter: https://www.bctengineer.com/md/semester_8/big_data_technologies/chapter-2

## Question

What is the main role of GFS Master during read and write processes? How data and control messages flow in GFS architecture? Explain with suitable flow diagram.

## Short answer

The master stores metadata, returns chunk locations for reads, and grants leases to choose a primary for writes, while data flows directly from client to chunkservers and control messages go through the master and primary. Reads request location then contact the nearest replica.

## Answer

#### Role of the GFS master
The master is the single metadata server and coordinator of the cluster. It does **not** carry file data, it only guides.

During **read**:
- Keeps the namespace and file-to-chunk mapping.
- Given file name and chunk index, returns the chunk handle and the locations of its replicas to the client.

During **write / append**:
- Decides which chunkserver holds the **lease** for the chunk and makes it the **primary** (lease normally 60 s, extendable).
- Returns the identity of the primary and secondary replicas to the client.
- Creates new chunks when needed, places replicas across racks and disks, and keeps chunk version numbers to detect stale replicas.

Other tasks: heartbeat monitoring, re-replication when replicas are lost, load balancing, garbage collection, and operation-log management.

#### Read flow
1. The client translates (file name, byte offset) into a chunk index using the fixed chunk size.
2. It sends (file name, chunk index) to the master.
3. The master replies with the chunk handle and replica locations; the client caches this.
4. The client sends the read request to the closest replica, which returns the data.

#### Write flow (control and data)
```text
 Client                Master          Primary    Secondaries
   |-- 1 who holds lease? -->|             |           |
   |<-- 2 primary+replicas --|             |           |
   |-- 3 push data ------------------------>--------->  (data flow,
   |      (chained to all replicas, cached in buffers)    pipelined)
   |-- 4 write request ------------------>|           |
   |                        |      5 assign serial     |
   |                        |      number, apply       |
   |                        |             |-- 5 fwd -->|
   |                        |             |<-- 6 ack --|
   |<-- 7 reply (success or error) -------|           |
```
1. Client asks the master which chunkserver holds the lease and where the other replicas are.
2. The master replies with the primary and secondary replicas.
3. The client **pushes data** to all replicas; data flows along a chain from nearest to nearest (to use each machine's network bandwidth fully) and is held in a buffer (LRU) by each chunkserver.
4. After all replicas confirm receipt, the client sends the write request to the primary.
5. The primary assigns consecutive serial numbers to all mutations, applies them locally, and forwards the request to the secondaries, which apply them in the same order.
6. The secondaries reply to the primary when finished.
7. The primary replies to the client; any errors are reported and the client retries.

#### Control vs data flow
- **Control messages** (metadata requests, lease grants, write request/commit order) go between client, master and primary.
- **Data** goes directly from the client to chunkservers, and between chunkservers in a pipeline; it never passes through the master. This keeps the master from being a bottleneck.

#### Message summary
| Message | From to | Type |
|---|---|---|
| File name + chunk index | Client to Master | Control |
| Chunk handle + replica list | Master to Client | Control |
| Data to be written | Client to chunkservers (chain) | Data |
| Write request | Client to Primary | Control |
| Order forwarded | Primary to Secondaries | Control |
| Completion ack | Secondaries to Primary to Client | Control |
| File data (read) | Chunkserver to Client | Data |

The data path is decoupled from the control path: data is pushed along a chain of chunkservers to use each machine's full outgoing bandwidth, while control follows a primary-secondary model that guarantees the same mutation order on all replicas.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. During a write, what does the GFS master do?
   A. Receives the file data and writes it to chunkservers
   B. Applies mutations in serial order
   C. Decides the lease holder (primary) and returns primary and secondary locations to the client
   D. Computes checksums for the client
   Answer: C. The master grants the lease to a primary and tells the client the replica locations; it never carries data. (Key point: Master's role in write)

2. How is data pushed to the replicas in a write?
   A. Client sends data only to the primary, which sends it to the master
   B. Client sends data to the master first
   C. Data goes through the secondaries to the primary
   D. Along a chain of chunkservers from nearest to nearest, buffered at each before the write request
   Answer: D. Chained pushing uses each machine's full outgoing bandwidth, and data is buffered until the write request arrives. (Key point: Data flow in write)

3. What does the primary do after it receives the write request?
   A. Assigns consecutive serial numbers to mutations, applies them and forwards the order to secondaries
   B. Sends the data to the master
   C. Waits for the master to order the writes
   D. Deletes the buffered data
   Answer: A. The primary's serial numbering ensures all replicas apply mutations in the same order. (Key point: Primary orders mutations)

4. Which message is a data message rather than a control message?
   A. Chunk handle plus replica list from the master
   B. Write request to primary
   C. Completion ack from secondaries
   D. Data pushed from client to chunkservers
   Answer: D. Data goes directly from client to chunkservers; metadata, lease and ordering messages are control and use the master and primary. (Key point: Control versus data flow)

## Related in Big Data Technologies

- [Single master not a GFS bottleneck](https://www.bctengineer.com/question.md?key=semester_8%2Fbig_data_technologies%3Agfs-single-master-bottleneck) — Big Data Technologies, chapter 2
- [Short note: Client-Server and Master-Slave](https://www.bctengineer.com/question.md?key=semester_8%2Fbig_data_technologies%3Ashort-note-client-server-master-slave) — Big Data Technologies, chapter 1
- [Role of data scientist in big data](https://www.bctengineer.com/question.md?key=semester_8%2Fbig_data_technologies%3Arole-of-data-scientist) — Big Data Technologies, chapter 1, asked 2×
- [Short note: Shadow Master and Cluak](https://www.bctengineer.com/question.md?key=semester_8%2Fbig_data_technologies%3Ashort-note-shadow-master-cluak) — Big Data Technologies, chapter 2
- [GFS vs other file systems](https://www.bctengineer.com/question.md?key=semester_8%2Fbig_data_technologies%3Agfs-differ-other-fs) — Big Data Technologies, chapter 2
- [Large fixed-size chunks in GFS](https://www.bctengineer.com/question.md?key=semester_8%2Fbig_data_technologies%3Agfs-large-fixed-chunks) — Big Data Technologies, chapter 2

## Related in other subjects

- [GFS vs HDFS architecture](https://www.bctengineer.com/question.md?key=semester_8%2Finformation_system%3Agfs-vs-hdfs) — Information System, chapter 8
- [Flow control mechanisms in data communication](https://www.bctengineer.com/question.md?key=semester_8%2Ftelecommunications%3Aflow-control-mechanisms) — Telecommunications, chapter 8
- [Flow control in data communication network](https://www.bctengineer.com/question.md?key=semester_8%2Ftelecommunications%3Aflow-control-network) — Telecommunications, chapter 8
- [Segregation and bleeding; control during placing](https://www.bctengineer.com/question.md?key=semester_5%2Fconcrete_technology_and_masonry_structure%3Asegregation-bleeding-control) — Concrete Technology and Masonry Structure, chapter 3
