目录
正在加载目录…
正在阅读专栏 分布式共识系统专栏 第 12 篇 · 共 59 篇 · 20%

MIT 6.5840:Lecture 03 GFS

发布于 2026-09-21 10:05 · 最后编辑于 2026-09-21 18:14 · 版本 v2 · 字数 19,115 · 预计阅读 39 分钟 👁 23 次阅读

MIT 6.5840:Lecture 03 GFS

本篇逐行译注 MIT 6.5840 Spring 2026 Lecture 3,围绕 GFS 的分片、复制、primary-backup、lease、一致性取舍和故障恢复,连接后续分布式存储与复制状态机主题。

TL;DR

  • GFS 的核心拆分:coordinator 负责命名和元数据,chunkserver 负责数据;文件被切成大 chunk 并分布到多台机器上。
  • 吞吐来自并行:客户端直接访问 chunkserver,不让 coordinator 进入数据路径;不同 chunk 可以在多个服务器上并行读写。
  • 复制协议:每个 chunk 通常有三个副本,写入由 primary 选择顺序,再让 secondaries 按相同顺序应用。
  • lease 的作用:在 coordinator 无法区分“primary 崩溃”和“网络隔离”时,lease 防止新旧 primary 同时活跃造成 split brain。
  • 一致性取舍:GFS 允许失败写入后出现不同副本看到不同内容,也用 atomic append 规避跨 chunk 并发写的严重数据丢失;这是围绕批处理应用做出的工程取舍。
  • 单点边界:单一 coordinator 的 RAM、CPU、fail-over 和小文件能力最终成为瓶颈,后来 Google 的系统沿着分片 coordinator 和更强的一致性方向演进。

名词解释

名词含义本讲对应物
GFSGoogle File System面向 Google 内部 batch big-data 工作负载的分布式文件系统
Chunk文件被切分后的大块数据原文中的 64 MB 数据块
Chunkserver保存 chunk 数据副本的服务器直接服务客户端读写数据
Coordinator保存文件名、chunk handle 和服务器位置的协调者不进入正常数据读写路径
Primary / Secondaryprimary-backup 复制中的主副本和从副本primary 选择写入顺序,secondaries 跟随应用
Lease在一段时间内担任某个 chunk primary 的授权防止旧 primary 尚未停止时产生新 primary
Atomic append由 primary 选择写入偏移的原子追加减少并发写入跨 chunk 时的数据丢失
Split brain两个节点都认为自己是当前 primary可能导致写入与读取分别落在不同状态上
Fail-stop failure节点停止工作但不主动产生错误值与 Byzantine failure 相对

目录

章节内容
版本与来源固定 Lecture 3 和 GFS 论文资料
原文逐行翻译按 l-gfs.txt 原顺序译注
机制小结把讲义中的读写、复制、lease 和故障路径串起来
本篇验收源文件、图件与译文边界

版本与来源

  • 课程版本:MIT 6.5840 Spring 2026。
  • Lecture 源文件:l-gfs.txt,351 行,SHA-256:9d0b8dcf7320d37c7013eee5264bda1aaa28d735149efc5d304d496105fee2af。
  • 配套论文:The Google File System,Sanjay Ghemawat、Howard Gobioff、Shun-Tak Leung,SOSP 2003。
  • 配套 FAQ:GFS FAQ。
  • 课程日程:MIT 6.5840 Spring 2026 Schedule。
  • 翻译边界:英文源行按原顺序保留,随后紧跟中文译文;术语如 chunk、primary、lease、split brain、Byzantine 和 fail-stop 保留英文或中英并列。
  • 图片结论:本 Lecture 源文件没有独立图片文件;[diagram: ...] 等文字占位按原位置保留。GFS 论文中的 Figure 不在本篇伪装成图片译入,后续若建立论文层笔记再单独处理。

原文逐行翻译

课程主题与论文动机

6.5840 2026 Lecture 3: GFS

6.5840 2026 年 Lecture 3:GFS。

The Google File System

《The Google File System(Google 文件系统)》。

Sanjay Ghemawat, Howard Gobioff, and Shun-Tak Leung

作者:Sanjay Ghemawat、Howard Gobioff 和 Shun-Tak Leung。

SOSP 2003

发表于 SOSP 2003。

Why are we reading this paper?

我们为什么要阅读这篇论文?

GFS paper touches on many themes of 6.5840

GFS 论文涉及 6.5840 的许多主题:

parallel performance, fault tolerance, replication, consistency

包括 parallel performance、fault tolerance、replication 和 consistency。

good systems paper -- details from apps all the way to network

这是一篇优秀的 systems paper——细节从应用一直延伸到网络。

successful real-world design

它还是一个成功的真实世界系统设计。

Important distributed system ideas

重要的 distributed system ideas:

Build fault-tolerant applications using fault-tolerant storage

使用 fault-tolerant storage 构建 fault-tolerant applications。

Sharding

Sharding。

Primary-backup replication protocol

Primary-backup replication protocol。

Leases to ensure 1 primary

使用 leases 确保只有一个 primary。

Checksums for detecting faulty hardware/software

使用 checksums 检测有故障的 hardware/software。

Sacrifice consistency for performance/simplicity

为了 performance/simplicity 而牺牲 consistency。

GFS 的背景

GFS context

GFS 的背景。

Many Google services needed a big fast unified storage system

Google 的许多服务都需要一个容量大、速度快的统一存储系统。

Mapreduce, crawler, indexer, log storage/analysis

包括 MapReduce、crawler、indexer,以及 log storage/analysis。

Shared among multiple applications e.g. crawl, index, analyze

它由多个应用共享,例如 crawl、index 和 analyze。

Huge capacity

需要巨大的容量。

Huge performance

需要很高的性能。

Fault tolerant

需要 fault tolerance。

But:

但是:

just for internal Google use

它只供 Google 内部使用。

aimed at batch big-data performance, not interactive

它的目标是 batch big-data performance,而不是 interactive 工作负载。

GFS 总览

GFS overview

GFS 总览。

100s/1000s of clients (e.g. MapReduce worker machines)

数百到数千个 clients(例如 MapReduce worker machines)。

100s of chunkservers, each with its own disk

数百个 chunkservers,每个 chunkserver 都有自己的磁盘。

one coordinator

一个 coordinator。

Capacity story?

容量是如何实现的?

big files split into 64 MB chunks

大文件被切分成 64 MB 的 chunks。

each file's chunks striped/sharded over chunkservers

每个文件的 chunks 都以 striped/sharded 的方式分布到多个 chunkservers 上。

so a file can be much larger than any one disk

因此,一个文件可以远大于任何一块磁盘的容量。

each chunk in a Linux file

每个 chunk 都存储在一个 Linux file 中。

Throughput story?

吞吐量是如何实现的?

clients talk directly to chunkservers to read/write data

clients 直接与 chunkservers 通信,读写数据。

if lots of clients access different chunks, huge parallel throughput

如果大量 clients 访问不同的 chunks,就能获得很高的并行吞吐量。

read or write

无论是 read 还是 write 都如此。

Fault tolerance story?

容错是如何实现的?

each 64 MB chunk stored (replicated) on three chunkservers

每个 64 MB chunk 都存储(replicated)在三个 chunkservers 上。

client writes are sent to all of a chunk's copies

client 的写入会发送给某个 chunk 的所有副本。

a read just needs to consult one copy

一次 read 只需要访问其中一个副本。

读取路径

What are the steps when client C wants to read a file?

当 client C 想读取一个文件时,步骤是什么?

  1. C sends filename and offset to coordinator (CO) (if not cached)
  1. C 把 filename 和 offset 发送给 coordinator(CO)(如果本地没有缓存)。
 CO has a filename -> array-of-chunkhandle table

CO 维护一个 filename → array-of-chunkhandle 的表。

 and a chunkhandle -> list-of-chunkservers table

同时维护一个 chunkhandle → list-of-chunkservers 的表。

  1. CO finds chunk handle for that offset
  1. CO 找到该 offset 对应的 chunk handle。
  1. CO replies with chunkhandle + list of chunkservers
  1. CO 返回 chunkhandle 和 chunkservers 列表。
  1. C caches handle + chunkserver list
  1. C 缓存 handle 和 chunkserver 列表。
  1. C sends request to nearest chunkserver
  1. C 向距离最近的 chunkserver 发送请求。
 chunk handle, offset

请求中包含 chunk handle 和 offset。

  1. chunk server reads from chunk file on disk, returns to client
  1. chunkserver 从磁盘上的 chunk file 读取数据,并返回给 client。

Clients only ask coordinator where to find a file's chunks

Clients 只向 coordinator 询问文件的 chunks 位于哪里。

clients cache name -> chunkhandle info

clients 会缓存 name → chunkhandle 信息。

coordinator does not handle data, so (hopefully) not heavily loaded

coordinator 不处理数据,因此(希望如此)不会承受很重的负载。

写入与复制

What about writes?

那么写入呢?

Client knows which chunkservers hold replicas that must be updated.

Client 知道哪些 chunkservers 持有必须更新的副本。

How should we manage updating of replicas of a chunk?

我们应该如何管理一个 chunk 的副本更新?

A bad replication scheme

一个糟糕的 replication scheme。

(This is not what GFS does)

(这不是 GFS 的做法。)

[diagram: C, S1, S2, S3]

[diagram: C, S1, S2, S3](原文 diagram 占位,保留在此处。)

Client sends update to each replica chunkserver

Client 向每个 replica chunkserver 发送更新。

Each chunkserver applies the update to its copy

每个 chunkserver 都把更新应用到自己的副本。

What can go wrong?

可能出什么问题?

Two clients write the same data at the same time

两个 clients 同时写入同一份数据。

i.e. "concurrent writes"

也就是“concurrent writes”。

Chunkservers may see the updates in different orders!

不同 chunkservers 看到这些更新的顺序可能不同!

Again, the risk is that, later, two clients may read different content

再次强调,风险在于:之后两个 clients 可能读到不同的内容。

Idea: primary/secondary replication

思路:primary/secondary replication。

(or primary/backup)

(也称 primary/backup。)

For each chunk, designate one server as "primary".

对每个 chunk,指定一台服务器作为“primary”。

Clients send write requests just to the primary.

Clients 只向 primary 发送写请求。

The primary alone manages interactions with secondary servers.

由 primary 单独管理与 secondary servers 的交互。

(Some designs send reads just to primary, some also to secondaries)

(有些设计只向 primary 发送 reads,有些设计也会向 secondaries 发送 reads。)

The primary chooses the order for all client writes.

primary 为所有 client writes 选择顺序。

Tells the secondaries -- with sequence numbers -- so all replicas

它通过带有 sequence numbers 的消息通知 secondaries,使所有 replicas

apply writes in the same order, even for concurrent client writes.

即使面对 concurrent client writes,也按相同顺序应用 writes。

There are still many details to fill in, and we'll

这里仍有许多细节需要补充,我们将在后续内容中

see a number of variants in upcoming papers.

通过接下来的论文看到多种变体。

GFS 写入步骤

What are the steps when C wants to write a file at some offset?

当 C 想在某个 offset 写入文件时,步骤是什么?

paper's Figure 2

论文中的 Figure 2。

  1. C asks CO about file's chunk @ offset
  1. C 向 CO 询问文件在该 offset 处对应的 chunk。
  1. CO tells C the primary and secondaries
  1. CO 告诉 C primary 和 secondaries 是哪些服务器。
  1. C sends data to all (just temporary...), waits for all replies (?)
  1. C 把数据发送给所有副本(只是临时保存……),并等待所有 replies(?)。
  1. C asks P to write
  1. C 请求 P 执行 write。
  1. P checks that lease hasn't expired
  1. P 检查 lease 是否尚未过期。
  1. P writes its own chunk file (a Linux file)
  1. P 写入自己的 chunk file(一个 Linux file)。
  1. P tells each secondary to write (copy temporary into chunk file)
  1. P 告诉每个 secondary 执行 write(把临时数据复制到 chunk file)。
  1. P waits for all secondaries to reply, or timeout
  1. P 等待所有 secondaries 回复,或者发生 timeout。
 secondary can reply "error" e.g. out of disk space

secondary 可以回复“error”,例如磁盘空间不足。

  1. P tells C "ok" or "error"
  1. P 告诉 C“ok”或“error”。
  1. C retries from start if error
  1. 如果出现 error,C 从头开始 retry。

失败写入与并发写入

What data may a client read after a failed write?

一次写入失败后,client 可能读到什么数据?

Replicas may return different data

不同 replicas 可能返回不同的数据。

Primary P updated its own state.

Primary P 更新了自己的状态。

But secondary S1 did not update (failed? slow? network problem?).

但 secondary S1 没有更新(是失败了?太慢?还是网络问题?)。

Client C1 reads from P; Client C2 reads from S1.

Client C1 从 P 读取;Client C2 从 S1 读取。

they will see different results!

它们会看到不同的结果!

Such a departure from ideal behavior is an "anomaly".

这种偏离理想行为的情况称为“anomaly”。

in non-replicated systems, this couldn't happen!

在 non-replicated systems 中,这种情况不会发生!

data can be inconsistent

数据可能是 inconsistent 的。

Note: a successful writes doesn't lead to inconsistency

注意:一次成功的 write 不会导致 inconsistency。

What is the result of concurrent writes?

concurrent writes 的结果是什么?

Clients break writes spanning chunks into two writes

Clients 会把跨越多个 chunks 的 write 拆成两个 writes。

C1 writes chunks x and y at offset 0 and 1, respectively

C1 分别在 offset 0 和 1 向 chunks x 和 y 写入。

C2 writes chunks a b at offset 0 and 1

C2 在 offset 0 和 1 写入 chunks a 和 b。

A possible state of the replicas (without errors): [a y]

在没有 errors 的情况下,replicas 可能处于 [a y] 状态。

x was overwritten by a

x 被 a 覆盖了。

b was overwritten with y

b 被 y 覆盖了。

x and b are lost!

x 和 b 丢失了!

Atomic append 与一致性

GFS solution: atomic append of records

GFS 的解决方案:对 records 执行 atomic append。

Primary picks the offset and pads if record spans chunks

由 primary 选择 offset;如果 record 跨越 chunks,就进行 padding。

Result for the above case: some interleaving of [a, b, x, and y]

对于上面的例子,结果是 [a, b, x, y] 的某种交错排列。

No data lost, but "empty" areas due to padding

没有数据丢失,但会因为 padding 出现“empty”区域。

Note: client doesn't determine where the data is in the file

注意:client 不决定数据在文件中的位置。

primary picks the offset

由 primary 选择 offset。

append returns offset where client's record is written

append 会返回 client 的 record 被写入的 offset。

Note: requires changing applications to use append instead of write

注意:这要求应用改用 append,而不是 write。

What data may a client read after a failed append?

一次 append 失败后,client 可能读到什么数据?

Read from a backup that has the record

从包含该 record 的 backup 读取。

Read from a backup that didn't apply the append: a hole

从没有应用该 append 的 backup 读取:看到一个 hole。

Read from a backup that recorded the initial and retried append

从同时记录了初次 append 和 retry append 的 backup 读取。

duplicate records

结果是 duplicate records。

Consistency: guarantees offered by a storage system to applications

Consistency:存储系统向应用提供的 guarantees。

GFS consistency is complex! (Table 1)

GFS 的 consistency 很复杂!(见 Table 1。)

if primary tells client that a write succeeded,

如果 primary 告诉 client 某次 write 成功了,

and no other client is writing the same part of the file,

并且没有其他 client 正在写入文件的同一部分,

all readers will see the write.

所有 readers 都会看到这次 write。

"defined"

这称为“defined”。

if successful concurrent writes to the same part of a file,

如果对文件同一部分的 concurrent writes 都成功了,

and they all succeed,

并且它们全部成功,

all readers will see the same content,

所有 readers 都会看到相同的内容,

but maybe it will be a mix of the writes.

但这个内容可能是多次 writes 的混合。

"consistent"

这称为“consistent”。

E.g. C1 writes "ab", C2 writes "xy", everyone might see "xb".

例如,C1 写入“ab”,C2 写入“xy”,所有人都可能看到“xb”。

if primary doesn't tell the client that the write succeeded,

如果 primary 没有告诉 client 这次 write 成功,

different readers may see different content, or none.

不同 readers 可能看到不同的内容,或者什么也看不到。

"inconsistent"

这称为“inconsistent”。

为什么这些 anomaly 可以接受

Why are these anomalies OK?

为什么这些 anomalies 是可以接受的?

They only intended to support a certain subset of their own applications.

他们只打算支持自己应用中的某个子集。

Written with knowledge of GFS's behavior.

这些应用是在了解 GFS 行为的前提下编写的。

Probably mostly single-writer and Record Append.

应用很可能主要使用 single-writer 和 Record Append。

Writers could include checksums and record IDs.

writers 可以加入 checksums 和 record IDs。

Readers could use them to filter out junk and duplicates.

readers 可以利用它们过滤掉 junk 和 duplicates。

Later commentary by Google engineers suggests that it

Google 工程师后来的评论表明,

might have been better to make GFS more consistent.

也许让 GFS 具有更强的 consistency 会更好。

http://queue.acm.org/detail.cfm?id=1594206

http://queue.acm.org/detail.cfm?id=1594206。

What might better consistency look like?

更好的 consistency 可能是什么样?

There are many possible answers.

可能有很多答案。

Trade-off between easy-to-use for client application programmers,

这是 client application programmers 易于使用,

and easy-to-implement for storage system designers.

与 storage system designers 易于实现之间的 trade-off。

Maybe try to mimic local disk file behavior.

也许可以尝试模拟 local disk file 的行为。

Perhaps:

例如:

* atomic writes: either all replicas are updated, or none,
  • atomic writes:要么所有 replicas 都被更新,要么一个都不更新,
  even if failures.

即使发生 failures 也是如此。

* read sees latest write.
  • read 能看到 latest write。
* all readers see the same content (assuming no writes).
  • 所有 readers 都看到相同的内容(假设期间没有 writes)。

We'll see more precision later.

之后我们会看到更精确的定义。

各类崩溃

Let's think about how GFS handles crashes of various entities.

下面思考 GFS 如何处理各种实体的 crashes。

A client crashes while writing?

如果 client 在写入过程中 crash 了呢?

Either it got as far as asking primary to write, or not.

要么它已经走到了请求 primary 执行 write 的步骤,要么还没有。

A secondary crashes just as the primary asks it to write?

如果 secondary 恰好在 primary 请求它 write 时 crash 了呢?

  1. Primary may retry a few times, if secondary revives quickly
  1. Primary 可以 retry 几次;如果 secondary 很快恢复,
 with disk intact, it may execute the primary's request

并且磁盘内容仍然完好,那么它可能执行 primary 的 request,

 and all is well.

一切就没问题了。

  1. Primary gives up, and returns an error to the client.
  1. Primary 放弃,并向 client 返回 error。
 Client can retry -- but why would the write work the second time around?

Client 可以 retry——但为什么第二次 write 就会成功呢?

  1. Coordinator notices that a chunkserver is down.
  1. Coordinator 注意到某个 chunkserver 已经 down。
 Periodically pings all chunk servers.

它会周期性地 ping 所有 chunk servers。

 Removes the failed chunkserver from all chunkhandle lists.

从所有 chunkhandle 列表中移除失败的 chunkserver。

 Perhaps re-replicates, to maintain 3 replicas.

也许还会执行 re-replication,以维持 3 个 replicas。

 Tells primary the new secondary list.

并把新的 secondary 列表告诉 primary。

Re-replication after a chunkserver failure may take a Long Time.

chunkserver failure 之后的 re-replication 可能需要很长时间。

Since a chunkserver failure requires re-replication of all its chunks.

因为 chunkserver failure 要求对该服务器上的所有 chunks 进行 re-replication。

80 GB disk, 10 MB/s network -> an hour or two for full copy.

一块 80 GB 的磁盘、10 MB/s 的网络,完整复制需要一到两个小时。

So the primary probably re-tries for a while,

因此 primary 可能会 retry 一段时间,

and the coordinator lets the system operate with a missing

而 coordinator 允许系统在缺少一个

chunk replica,

chunk replica 的情况下继续运行,

before declaring the chunkserver permanently dead.

然后才宣布该 chunkserver 已永久死亡。

How long to wait before re-replicating?

在 re-replicating 之前应该等待多久?

Too short: wasted copying work if chunkserver comes back to life.

太短:如果 chunkserver 恢复,就浪费了复制工作。

Too long: more failures might destroy all copies of data.

太长:更多 failures 可能会摧毁数据的所有 copies。

Primary、lease 与 split brain

What if a primary crashes?

如果 primary crash 了呢?

Remove that chunkserver from all chunkhandle lists.

从所有 chunkhandle 列表中移除该 chunkserver。

For each chunk for which it was primary,

对于它曾经担任 primary 的每个 chunk,

wait for lease to expire,

等待 lease 过期,

grant lease to another chunkserver holding that chunk.

然后把 lease 授予另一个持有该 chunk 的 chunkserver。

What is a lease?

什么是 lease?

Permission to act as primary for a given time (60 seconds).

在指定时间内(60 秒)担任 primary 的 permission。

Primary promises to stop acting as primary before lease expires.

Primary 承诺在 lease 过期之前停止以 primary 身份行动。

Coordinator promises not to change primaries until after expiration.

Coordinator 承诺在 lease 过期之前不更换 primary。

Separate lease per actively written chunk.

每个正在 active write 的 chunk 都有独立的 lease。

Why are leases helpful?

为什么 leases 有帮助?

The coordinator must be able to designate a new primary if the present

如果当前

primary fails.

primary failure,coordinator 必须能够指定新的 primary。

But the coordinator cannot distinguish "primary has failed" from

但是 coordinator 无法区分“primary 已经 failure”

"primary is still alive but the network has a problem."

和“primary 仍然存活但网络出了问题”。

What if the coordinator designates a new primary while old one is active?

如果 coordinator 在旧 primary 仍 active 时指定了新的 primary,会怎样?

two active primaries!

就会有两个 active primaries!

C1 writes to P1, C2 reads from P2, doesn't seen C1's write!

C1 向 P1 写入,C2 从 P2 读取,却看不到 C1 的 write!

called "split brain" -- a disaster

这称为“split brain”——一种灾难。

Leases help prevent split brain:

Leases 有助于防止 split brain:

Coordinator won't designate new primary until the current one is

Coordinator 不会指定新的 primary,直到当前 primary

guaranteed to have stopped acting as primary.

能够被保证已经停止以 primary 身份行动。

Coordinator 故障与恢复

What if the coordinator crashes?

如果 coordinator crash 了呢?

Two strategies.

有两种策略。

  1. Coordinator writes critical state to its disk.
  1. Coordinator 把 critical state 写入自己的磁盘。
 If it crashes and reboots with disk intact,

如果它 crash 后重启,并且磁盘完好,

 re-reads state, resumes operations.

它就重新读取 state,恢复 operation。

  1. Coordinator sends each state update to a "backup coordinator",
  1. Coordinator 把每次 state update 发送给“backup coordinator”,
 which also records it to disk; backup coordinator can take

后者也把 update 记录到磁盘;如果主 coordinator 无法重启,

 over if main coordinator cannot be restarted.

backup coordinator 就可以接管。

What information must the coordinator save to disk to recover from crashes?

为了从 crashes 中恢复,coordinator 必须把哪些信息保存到磁盘?

Table mapping file name -> array of chunk handles.

把 file name 映射到 chunk handles 数组的表。

Table mapping chunk handle -> current version #.

把 chunk handle 映射到 current version number 的表。

What about the list of chunkservers for each chunk?

那么每个 chunk 对应的 chunkservers 列表呢?

A rebooted coordinator asks all the chunkservers what they store.

重启后的 coordinator 会询问所有 chunkservers 它们存储了什么。

A rebooted coordinator must also wait one lease time before

重启后的 coordinator 还必须等待一个 lease 周期,

designating any new primaries.

然后才能指定新的 primaries。

  • Who/what decides the coordinator is dead, and chooses a replacement?
  • 谁或什么机制决定 coordinator 已经死亡,并选择 replacement?

Paper does not say.

论文没有说明。

Could the coordinator replicas ping the coordinator,

coordinator replicas 是否可以 ping coordinator,

and automatically take over if no response?

如果没有 response,就自动接管?

  • Suppose the coordinator reboots, and polls chunkservers.
  • 假设 coordinator 重启,并轮询 chunkservers。

What if a chunkserver has a chunk, but it wasn't a secondary?

如果某个 chunkserver 有一个 chunk,但它并不是该 chunk 的 secondary 呢?

I.e. the current primary wasn't keeping it up to date?

也就是说,当前 primary 没有持续更新它?

Coordinator remembers version number per chunk, on disk.

Coordinator 在磁盘上记住每个 chunk 的 version number。

Increments each time it designates a new primary for the chunk.

每次为该 chunk 指定新的 primary 时,version number 都会递增。

Chunkserver also remembers its version number per chunk.

Chunkserver 也会记住每个 chunk 的 version number。

When chunkserver reports to coordinator, coordinator compares

当 chunkserver 向 coordinator 报告时,coordinator 会比较

version number, only accepts if current version.

version number,只有版本是 current version 时才接受它。

  • What if a client has cached a stale (wrong) primary for a chunk?
  • 如果 client 缓存了某个 chunk 的 stale(错误)primary 呢?
  • What if the reading client has cached a stale server list for a chunk?
  • 如果执行读取的 client 缓存了某个 chunk 的 stale server list 呢?
  • What if the primary crashes before sending append to all secondaries?
  • 如果 primary 在把 append 发送给所有 secondaries 之前 crash 了呢?

Could a secondary that didn't see the append be chosen as the new primary?

一个没有看到该 append 的 secondary 会不会被选为新的 primary?

Is it a problem that the other secondary did see the append?

另一个已经看到该 append 的 secondary 会不会造成问题?

Strict consistency

What would it take to have no anomalies -- strict consistency?

要做到没有 anomalies——也就是 strict consistency——需要什么?

I.e. all clients see the same file content.

也就是说,所有 clients 都看到同样的文件内容。

Too hard to give a real answer, but here are some issues.

很难给出真正完整的答案,但至少有以下问题。

  • All replicas should complete each write, or none -- "atomic write".
  • 所有 replicas 要么都完成一次 write,要么都不完成——这就是“atomic write”。
Perhaps tentative writes until all promise to complete it?

也许可以先执行 tentative writes,直到所有 replicas 都承诺完成它?

Don't expose writes until all have agreed to perform them!

在所有 replicas 都同意执行之前,不要让 writes 对外可见!

  • Primary should detect duplicate client write requests.
  • Primary 应该检测 client 重复发送的 write requests。
  • If primary crashes, some replicas may be missing the last few ops.
  • 如果 primary crash,一些 replicas 可能缺失最后几次 operations。
They must sync up.

它们必须完成同步。

  • Clients must be prevented from reading from stale ex-secondaries.
  • 必须阻止 clients 从 stale 的旧 secondaries 读取。

You'll see solutions in Labs 2, 3, and 4!

你会在 Labs 2、3 和 4 中看到解决方案!

  • Are there circumstances in which GFS will break its guarantees?
  • 是否存在 GFS 会破坏自身 guarantees 的情况?

e.g. write succeeds, but subsequent readers don't see the data.

例如,write 成功了,但后续 readers 看不到数据。

All coordinator replicas permanently lose state (permanent disk failure).

所有 coordinator replicas 永久丢失 state(永久磁盘 failure)。

Read will fail.

Read 会失败。

All chunkservers holding the chunk permanently lose disk content.

所有持有该 chunk 的 chunkservers 永久丢失磁盘内容。

Read will fail.

Read 会失败。

CPU, RAM, network, or disk yields an incorrect value.

CPU、RAM、network 或 disk 产生了错误的 value。

checksum catches some cases, but not all

checksum 可以捕获其中一些情况,但不是全部。

Read may say "success" but yield the wrong data!

Read 可能报告“success”,但返回错误的数据!

Above errors were "fail-stop", but this is a "byzantine" failure.

上面的 errors 属于“fail-stop”,而这里是“byzantine” failure。

Time is not properly synchronized, so leases don't work out.

如果时间没有正确同步,leases 就无法正常工作。

So multiple primaries, maybe write goes to one, read to the other.

于是可能出现多个 primaries,write 进入其中一个,read 却访问另一个。

Again, read may yield "success" but wrong data -- byzantine failure.

同样,read 可能报告“success”但返回错误数据——这是 byzantine failure。

性能与回顾

Performance (Figure 3)

性能(Figure 3)。

large aggregate throughput for read

read 具有很高的 aggregate throughput。

94 MB/sec total for 16 clients + 16 chunkservers

16 个 clients 加 16 个 chunkservers 的总吞吐量为 94 MB/sec。

  or 6 MB/second per client

也就是每个 client 6 MB/second。

  is that good?

这算好吗?

  one disk sequential throughput was about 30 MB/s

一块磁盘的 sequential throughput 约为 30 MB/s。

  one NIC was about 10 MB/s

一个 NIC 约为 10 MB/s。

Close to saturating inter-switch link's 125 MB/sec (1 Gbit/sec)

这已经接近把 inter-switch link 的 125 MB/sec(1 Gbit/sec)跑满。

So: multi-client scalability is good

因此,multi-client scalability 很好。

Table 3 reports 500 MB/sec for cluster A, which was a lot

Table 3 报告 cluster A 达到 500 MB/sec,这在当时是很高的数值。

writes to different files lower than possible maximum

向不同 files 写入时,性能低于理论 maximum。

authors blame their network stack (but no detail)

作者将其归因于 network stack(但没有给出细节)。

concurrent appends to single file

对单个 file 执行 concurrent appends 时,

limited by the server that stores last chunk

性能受限于存储最后一个 chunk 的 server。

hard to interpret after 15 years, e.g. how fast were the disks?

15 年后很难解读这些数据,例如当时的 disks 到底有多快?

Retrospective interview with GFS engineer:

一篇对 GFS 工程师的回顾性访谈:

http://queue.acm.org/detail.cfm?id=1594206

http://queue.acm.org/detail.cfm?id=1594206。

file count was the biggest problem

file count 是最大的问题。

eventual numbers grew to 1000x those in Table 2 !

最终数量增长到了 Table 2 中数字的 1000 倍!

hard to fit in coordinator RAM

很难放进 coordinator 的 RAM。

coordinator scanning of all files/chunks for GC is slow

coordinator 为 GC 扫描所有 files/chunks 的速度很慢。

1000s of clients -> too much CPU load on coordinator

数千个 clients → coordinator 承受了过高的 CPU 负载。

coordinator fail-over initially manual, 10s of minutes, too long.

coordinator 的 fail-over 最初是手动的,需要十几分钟,太慢了。

applications had to be designed to cope with GFS semantics

应用必须被设计成能够应对 GFS semantics,

and limitations.

以及它的 limitations。

more painful than expected.

这比预期更加痛苦。

BigTable is one answer to many-small-files problem

BigTable 是 many-small-files 问题的一种解决方案,

and Colossus apparently shards coordinator data over many coordinators

而 Colossus 显然把 coordinator data 分片到多个 coordinators 上。

总结

Summary

总结。

case study of performance, fault-tolerance, consistency

这是一个关于 performance、fault-tolerance 和 consistency 的 case study,

specialized for MapReduce applications

并针对 MapReduce applications 做了专门优化。

good ideas:

好的 ideas:

global cluster file system as universal infrastructure

把 global cluster file system 作为通用基础设施。

separation of naming (coordinator) from storage (chunkserver)

把 naming(coordinator)与 storage(chunkserver)分离。

sharding for parallel throughput

使用 sharding 获得 parallel throughput。

huge files/chunks to reduce overheads

使用巨大的 files/chunks 降低 overheads。

primary to choose order for concurrent writes

由 primary 为 concurrent writes 选择顺序。

leases to prevent split-brain

使用 leases 防止 split-brain。

not so great:

不那么理想的地方:

single coordinator performance

single coordinator 的性能。

  ran out of RAM and CPU

RAM 和 CPU 最终不够用了。

chunkservers not very efficient for small files

chunkservers 处理 small files 时效率不高。

lack of automatic fail-over to coordinator replica

缺少向 coordinator replica 自动 fail-over 的能力。

maybe consistency was too relaxed

也许 consistency 放得过宽松了。

http://queue.acm.org/detail.cfm?id=1594206

http://queue.acm.org/detail.cfm?id=1594206。

https://cloud.google.com/blog/products/storage-data-transfer/a-peek-behind-colossus-googles-file-system

https://cloud.google.com/blog/products/storage-data-transfer/a-peek-behind-colossus-googles-file-system。

机制小结

读写路径的职责分离

mermaid
flowchart LR
    Client[Client] -->|文件名和 offset| Coordinator[Coordinator]
    Coordinator -->|chunk handle 与服务器列表| Client
    Client -->|直接读写数据| Chunkserver[Chunkserver]
    Chunkserver --> Disk[Chunk file / disk]

GFS 把“找到数据”和“传输数据”分开:coordinator 负责元数据查询,chunkserver 负责数据路径。这种分离让 coordinator 避免成为所有字节都必须经过的中心瓶颈,但也把元数据规模、缓存失效和 coordinator 故障恢复变成核心问题。

复制与一致性的边界

mermaid
flowchart TD
    Client --> Primary
    Primary --> Secondary1[Secondary 1]
    Primary --> Secondary2[Secondary 2]
    Primary --> Commit[向 Client 返回结果]

primary 选择顺序并协调副本,不等于所有副本在任何失败时都已经拥有完全相同的状态。失败返回、重试、stale primary、旧 secondary 和 append 重复都会影响应用看到的内容;因此 GFS 的 guarantees 必须和应用使用模式一起理解。

与后续 6.5840 的连接

  • GFS 的 primary/secondary、lease 和副本同步,是理解后续 Raft、Paxos 和 replicated state machine 的工程背景。
  • GFS 允许较宽松的 consistency,而 Lab 3–5 会逐步要求持久化、提交索引、snapshot、线性一致性和客户端去重。
  • GFS 用大 chunk 和直接数据路径换取吞吐;后续系统会进一步讨论 coordinator 元数据分片、成员变更、事务和更强的一致性。

本篇验收

  • 已固定官方 l-gfs.txt 共 351 行,SHA-256 为 9d0b8dcf7320d37c7013eee5264bda1aaa28d735149efc5d304d496105fee2af。
  • Lecture 英文非空源行按原顺序逐行译注;原文中的术语、数字、URL 和 [diagram: ...] 占位保留在对应位置。
  • 本源文件没有独立 raster image;GFS 论文的 Figure 2、Figure 3 未在本篇冒充独立图片,后续论文层笔记再按原图位置处理。
  • 本篇是 Spring 2026 lecture track 的第 3 篇;下一篇为 Lecture 4《Paxos》。

参考资料

← 返回列表
← 上一篇 MIT 6.5840:Lecture 02 Threads and RPC 下一篇 → MIT 6.5840:Lecture 04 Fault-Tolerant Agreement and Paxos

评论 (0)

暂无评论,来留下第一条吧。
登录 或 注册 后才能发表评论