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

论文:MapReduce:Simplified Data Processing on Large Clusters

发布于 2026-09-21 10:08 · 最后编辑于 2026-09-21 18:15 · 版本 v2 · 字数 31,469 · 预计阅读 63 分钟 👁 25 次阅读

本篇整理 Google 的 MapReduce 论文。每一页保留原始 PDF 页面图;页面图是原文排版、Figure、统计表、伪代码、C++ 示例、脚注和参考文献的原始副本,下面按原页顺序给出中文译文与必要术语说明。

论文:MapReduce:Simplified Data Processing on Large Clusters

相关文章:6.5840:Lecture 01 Introduction · 6.5840:Lecture 03 GFS · 论文:The Google File System(GFS) · 论文:Bigtable:A Distributed Storage System for Structured Data

TL;DR

  • 解决的问题:把“对海量 input record 做变换,再按 key 聚合”的计算,抽象成用户只需实现 Map 与 Reduce 的 programming model。
  • 核心判断:限制 programming model,换取自动 parallelization、data partition、load balancing、fault tolerance、locality optimization 和 failure recovery。
  • 运行路径:input 被切成 M 个 map split;map 输出按 partition function 分成 R 个 intermediate partition;reduce worker 拉取、排序并聚合同一 intermediate key。
  • 容错机制:worker failure 通过重新执行 task 恢复;map output 因存于故障 worker 的 local disk 而必须重算,reduce output 因写入 global file system 通常无需重算;backup task 处理 straggler。
  • 边界与代价:master 是单点调度组件;中间数据经过 shuffle;side effect 需由 application 自己保证 atomic/idempotent;非 deterministic operator 的语义弱于顺序执行。

名词解释

名词含义本文对应物
Map对一个 input key/value pair 生成 intermediate key/value pair用户实现的 Map function
Reduce对同一 intermediate key 的全部 value 做聚合用户实现的 Reduce function
Map task处理一个 input split 的 taskM 个 map task
Reduce task处理一个 intermediate partition 的 taskR 个 reduce task,通常对应一个 output file
Shufflereduce worker 从 map worker 拉取 intermediate dataRPC 读取 local disk 上的 partition
Master跟踪 task、分配 worker、传播 intermediate location 的调度者单个 MapReduce operation 的 master
Straggler异常慢、拖住作业尾部的 worker/taskbackup task 的主要目标
Combiner在 map worker 本地做 partial aggregation 的可选 functionword count 中先合并 <the, 1>
Locality optimization尽量让 map task 在 input replica 所在机器或附近执行利用 GFS 的 block replica location

目录

章节内容
版本与来源OSDI ’04 版本、PDF 固定信息与翻译边界
原文页面与逐段翻译13 个 PDF 页面按顺序保留并翻译
机制索引model、execution、fault tolerance、locality 与 refinements
本篇验收页数、图片、Figure/Table 和 Appendix 覆盖范围

版本与来源

  • 论文标题:MapReduce: Simplified Data Processing on Large Clusters。
  • 作者与机构:Jeffrey Dean、Sanjay Ghemawat;Google, Inc.
  • 发表信息:6th Symposium on Operating Systems Design and Implementation(OSDI ’04),2004,pp. 137–150。
  • 官方来源:USENIX 论文页面;USENIX PDF;USENIX HTML。
  • 本地固定文件:source/mapreduce.pdf。
  • PDF 固定信息:13 页,每页 612×792 points;SHA-256:9cfef3ef1b8fe1a1b66c7221f56c2eeca0b15d6608ea68b0c85a38bfbffd8ce5。
  • 附件处理:每页渲染为 1224×1584 PNG,存放于 assets/40 MapReduce/,正文以 600 宽度嵌入。Figure 1–4、Table 1、Figure 2/3 的吞吐量图和 Appendix A 的完整 C++ 程序由原页图保留。
  • 翻译边界:以原文段落、伪代码、API、Figure/Table caption 和 References 为最小翻译单元;MapReduce、Map、Reduce、master、worker、task、shuffle、straggler、GFS、combiner 等术语保留 English 或中英并列。

原文页面与逐段翻译

第 1 页:Abstract、Introduction

mapreduce p01

标题与作者

MapReduce:大型集群上的简化数据处理

作者:Jeffrey Dean、Sanjay Ghemawat。

机构:Google, Inc.

Abstract

MapReduce 是一种用于处理和生成大型 data set 的 programming model,以及与之配套的 implementation。用户指定一个 Map function:它处理一个 key/value pair,并生成一组 intermediate key/value pair;用户还指定一个 Reduce function:它合并与同一个 intermediate key 关联的所有 value。正如本文所示,许多 real-world task 都可以表达为这种形式。

使用这种 functional style 编写的 program,会在大型 commodity machine cluster 上自动 parallelize 和执行。Runtime system 负责 input partition、program scheduling、machine failure 处理,以及所需的 inter-machine communication。这使得没有 parallel 和 distributed system 经验的 programmer,也能方便地使用大型 distributed system 的 resource。

我们的 MapReduce implementation 运行在大型 commodity machine cluster 上,并具有很好的 scalability:一次典型的 MapReduce computation 会在数千台 machine 上处理许多 terabytes 的 data。Programmer 发现该 system 很容易使用:已经实现了数百个 MapReduce program,并且 Google cluster 每天执行的 MapReduce job 超过一千个。

1 Introduction

过去五年中,作者和 Google 的许多其他人实现了数百种 special-purpose computation,用于处理大量 raw data(例如 crawled document、web request log),并计算各种 derived data,例如 inverted index、web document graph structure 的不同表示、每个 host 抓取页面数量的 summary,以及某一天中最常见的 query 集合。

这类 computation 大多在概念上很直接。然而,input data 通常很大,computation 必须分布到数百或数千台 machine 上,才能在合理时间内完成。如何 parallelize computation、如何分布 data、如何处理 failure,这些问题共同把原本简单的 computation 淹没在大量用于处理这些问题的复杂 code 中。

针对这种复杂性,我们设计了一种新的 abstraction:它能够表达我们试图执行的简单 computation,同时把 parallelization、fault-tolerance、data distribution 和 load balancing 的 messy detail 隐藏到一个 library 中。这个 abstraction 的灵感来自 Lisp 和许多其他 functional language 中的 map 与 reduce primitive。

我们发现,大多数 computation 都是在 input 中的每一个逻辑“record”上执行 map operation,以计算一组 intermediate key/value pair;随后对共享同一个 key 的所有 value 执行 reduce operation,以适当地合并 derived data。使用 user 指定的 map 和 reduce operation 组成的 functional model,让我们能够很容易地 parallelize large computation,并把 re-execution 作为 fault tolerance 的主要机制。

这项工作的主要贡献,是一个简单而强大的 interface:它支持 large-scale computation 的 automatic parallelization 和 distribution;同时还提供了一个面向大型 commodity PC cluster 的高性能 implementation。

第 2 节描述 basic programming model,并给出几个示例。第 3 节描述面向 cluster-based computing environment 定制的 MapReduce interface implementation。第 4 节描述我们发现有用的 programming-model refinement。第 5 节针对多种 task 测量 implementation performance。第 6 节讨论 Google 内部使用 MapReduce 的情况,包括把它作为 production indexing system 重写基础的经验。第 7 节讨论 related work 和 future work。

第 2 页:Programming Model、word count 与示例

mapreduce p02

2 Programming Model

这个 computation 接受一组 input key/value pair,并生成一组 output key/value pair。MapReduce library 的 user 用两个 function 表达 computation:Map 和 Reduce。

由 user 编写的 Map 接受一个 input pair,并生成一组 intermediate key/value pair。MapReduce library 把与同一个 intermediate key I 关联的所有 intermediate value 分组,然后传给 Reduce function。

同样由 user 编写的 Reduce 接受一个 intermediate key I 和该 key 对应的一组 value。它把这些 value 合并,形成一组可能更小的 value。通常,每次 Reduce invocation 只产生零个或一个 output value。Intermediate value 通过 iterator 提供给 user 的 reduce function,因此可以处理过大而无法放入 memory 的 value list。

2.1 Example

考虑在大型 document 集合中统计每个 word 出现次数的问题。User 可以编写类似以下 pseudo-code 的代码:

text
map(String key, String value):
  // key: document name
  // value: document contents
  for each word w in value:
    EmitIntermediate(w, "1");

reduce(String key, Iterator values):
  // key: a word
  // values: a list of counts
  int result = 0;
  for each v in values:
    result += ParseInt(v);
  Emit(AsString(result));

Map function 为每个 word 生成 word 和关联的 occurrence count(这个简单例子中 count 始终是 1)。Reduce function 把某个 word 对应的所有 count 加起来。

此外,user 还需要编写代码,向一个 MapReduce specification object 填入 input 和 output file 的 name,以及可选 tuning parameter。随后 user 调用 MapReduce function,并把 specification object 传给它。User code 会与 MapReduce library(用 C++ 实现)链接。Appendix A 包含这个例子的完整 program text。

2.2 Types

尽管前面的 pseudo-code 使用 string input 和 output 来描述,概念上,user 提供的 map 和 reduce function 具有如下 type:map(k1, v1) → list(k2, v2);reduce(k2, list(v2)) → list(v2)。

也就是说,input key/value 来自与 output key/value 不同的 domain。此外,intermediate key/value 与 output key/value 来自同一个 domain。

我们的 C++ implementation 在 user-defined function 间传递 string,至于如何在 string 与适当 type 之间转换,则留给 user code 负责。

2.3 More Examples

下面是一些很容易表达成 MapReduce computation 的有趣 program 示例。

  • Distributed Grep:Map function 在一行匹配给定 pattern 时输出该行;Reduce function 是 identity function,只把收到的 intermediate data 复制到 output。
  • Count of URL Access Frequency:Map function 处理 web-page request log,输出 ⟨URL, 1⟩;Reduce function 把同一 URL 的所有 value 相加,输出 ⟨URL, total count⟩ pair。
  • Reverse Web-Link Graph:对于名为 source 的 page 中指向 target URL 的每条 link,Map function 输出 ⟨target, source⟩ pair。Reduce function 把给定 target URL 对应的所有 source URL 列表连接起来,输出 ⟨target, list(source)⟩。
  • Term-Vector per Host:term vector 把 document 或 document 集合中最重要的 word 总结成 ⟨word, frequency⟩ pair 列表。Map function 为每个 input document 输出一个 ⟨hostname, term vector⟩ pair,其中 hostname 从 document URL 中提取。Reduce function 接收某个 host 的所有 per-document term vector,把这些 vector 相加,丢弃低频 term,然后输出最终的 ⟨hostname, term vector⟩ pair。

第 3 页:Inverted Index、Implementation 环境与 Execution Overview 引入

mapreduce p03

Inverted Index

Map function 解析每个 document,并为其生成一串 ⟨word, document ID⟩ pair。Reduce function 接收某个 word 对应的全部 pair,对相应的 document ID 排序,并输出 ⟨word, list(document ID)⟩ pair。所有 output pair 的集合就构成一个简单的 inverted index。很容易扩展这个 computation,使它同时记录 word position。

Distributed Sort

Map function 从每条 record 中提取 key,并生成 ⟨key, record⟩ pair。Reduce function 原样输出所有 pair。这个 computation 依赖第 4.1 节描述的 partitioning facility,以及第 4.2 节描述的 ordering property。

3 Implementation

MapReduce interface 有许多种可能的 implementation;正确的选择取决于 environment。例如,一种实现可能适合小型 shared-memory machine,另一种适合大型 NUMA multiprocessor,另一种则适合更大规模的 networked machine 集合。

本节描述一种面向 Google 广泛使用的 computing environment 的 implementation:通过 switched Ethernet 连接的大型 commodity PC cluster [4]。我们的 environment 具有以下特征:

  1. Machine 通常是运行 Linux 的 dual-processor x86 processor,每台 machine 有 2–4GB memory。
  2. 使用 commodity networking hardware:machine level 通常是 100 megabit/s 或 1 gigabit/s,但整体 bisection bandwidth 的平均值明显更低。
  3. 一个 cluster 包含数百或数千台 machine,因此 machine failure 很常见。
  4. Storage 由直接连接到单台 machine 的廉价 IDE disk 提供。一个内部开发的 distributed file system [8] 用于管理这些 disk 上的数据。该 file system 使用 replication,在不可靠 hardware 之上提供 availability 和 reliability。
  5. User 向 scheduling system 提交 job。每个 job 由一组 task 组成,scheduler 把这些 task 映射到 cluster 中的一组可用 machine。
3.1 Execution Overview

Map invocation 会通过把 input data 自动 partition 成 M 个 split,分布到多台 machine。不同 machine 可以并行处理 input split。Reduce invocation 则通过使用 partitioning function 把 intermediate key space 划分成 R 个 piece。R 和 partitioning function 由 user 指定。

Figure 1:Execution overview

原图展示完整 execution flow:User Program 调用 MapReduce library;library fork 出 master 和多个 worker;master 把 input split 分给 map worker,把 intermediate partition 分给 reduce worker;map phase 在 local disk 写 intermediate file;reduce phase 从 map worker remote read,最终写入 output file 0、output file 1 等 output file。

第 4 页:Execution Overview 详细步骤与 Worker Failure

mapreduce p04

Figure 1 展示了我们 implementation 中一次 MapReduce operation 的总体流程。当 user program 调用 MapReduce function 时,会按如下顺序执行 action(Figure 1 中的编号对应下列编号):

  1. User program 中的 MapReduce library 首先把 input file 切成 M 个 piece,每个 piece 通常包含 16–64MB(MB),大小可以通过 optional parameter 由 user 控制。随后,它在 cluster 的 machine 上启动 program 的许多 copy。
  2. 其中一个 copy 具有特殊角色:它是 master。其余 copy 是由 master 分配 work 的 worker。需要分配的 work 包括 M 个 map task 和 R 个 reduce task。Master 选择 idle worker,并为每个 worker 分配 map task 或 reduce task。
  3. 被分配 map task 的 worker 读取相应 input split 的内容,从 input data 中解析 key/value pair,并把每个 pair 传给 user-defined Map function。Map function 产生的 intermediate key/value pair 会在 memory 中 buffer。
  4. 这些 buffer pair 会周期性写入 local disk,并由 partitioning function 划分成 R 个 region。Buffer pair 在 local disk 上的位置被回传给 master;master 负责把这些 location 转发给 reduce worker。
  5. Reduce worker 收到 master 关于这些 location 的通知后,通过 RPC 从 map worker 的 local disk 读取 buffered data。Reduce worker 读取完所有 intermediate data 后,按 intermediate key 排序,使同一个 key 的所有 occurrence 聚在一起。由于通常有多个不同 key 会映射到同一个 reduce task,因此需要排序;如果 intermediate data 太大而无法放入 memory,则使用 external sort。
  6. Reduce worker 遍历排序后的 intermediate data。对于遇到的每个 unique intermediate key,它把 key 以及对应的 intermediate value 集合传给 user 的 Reduce function。Reduce function 的 output append 到该 reduce partition 的 final output file。
  7. 所有 map task 和 reduce task 完成后,master 唤醒 user program。此时,user program 中的 MapReduce call 返回到 user code。

成功完成后,MapReduce execution 的 output 位于 R 个 output file 中,每个 reduce task 对应一个 file,file name 由 user 指定。通常,user 不需要把这 R 个 output file 合并成一个 file:它们经常被作为另一个 MapReduce call 的 input,或者被能够处理多个 partitioned file 的其他 distributed application 使用。

3.2 Master Data Structures

Master 为每个 map task 和 reduce task 保存 state(idle、in-progress 或 completed),并在 task 非 idle 时保存 worker machine 的 identity。

Master 是 intermediate file region location 从 map task 传播到 reduce task 的 conduit。因此,对每个 completed map task,master 保存该 map task 产生的 R 个 intermediate file region 的 location 和 size。Map task 完成时会收到关于 location 和 size 的 update;这些 information 被 incremental 地 push 给拥有 in-progress reduce task 的 worker。

3.3 Fault Tolerance

由于 MapReduce library 面向在数百或数千台 machine 上处理非常大量的 data,因此 library 必须优雅地容忍 machine failure。

Worker Failure

Master 周期性 ping 每个 worker。如果在一定时间内没有收到 worker response,master 就把该 worker 标记为 failed。该 worker 已完成的 map task 会被 reset 回 initial idle state,因此可以被调度到其他 worker 上。类似地,failed worker 上处于 in-progress 的 map task 或 reduce task 也会被 reset 为 idle,并可以重新调度。

Completed map task 在 failure 后需要重新执行,因为它的 output 存储在 failed machine 的 local disk 上,无法访问。Completed reduce task 通常不需要重新执行,因为它的 output 存储在 global file system 中。

如果 map task 先由 worker A 执行,随后由于 A failure 又由 worker B 执行,那么执行 reduce task 的 worker 会收到重新执行的通知。尚未从 worker A 读取 data 的 reduce task,将从 worker B 读取 data。

MapReduce 能够抵御大规模 worker failure。例如,一次 MapReduce operation 运行时,cluster 正在进行的 network maintenance 让每组约 80 台 machine 连续数分钟不可达。MapReduce master 只需重新执行不可达 worker machine 完成的 work,便能继续向前推进,并最终完成该 MapReduce operation。

第 5 页:Master Failure、Failure Semantics、Locality 与 Task Granularity

mapreduce p05

Master Failure

Master 可以很容易地为上面描述的 master data structure 周期性写 checkpoint。如果 master task 死亡,可以从最后一个 checkpointed state 启动新的 copy。不过,由于只有一个 master,它发生 failure 的概率较低;因此当前 implementation 在 master failure 时会 abort MapReduce computation。Client 可以检查这种情况,并在需要时 retry MapReduce operation。

Semantics in the Presence of Failures

当 user 提供的 map 和 reduce operator 是其 input value 的 deterministic function 时,我们的 distributed implementation 产生的 output,与整个 program 在无 failure 的情况下顺序执行所产生的 output 相同。

我们依赖 map 和 reduce task output 的 atomic commit 来实现这一 property。每个 in-progress task 都把 output 写入 private temporary file。一个 reduce task 产生一个这样的 file,一个 map task 则产生 R 个这样的 file(每个 reduce task 一个)。Map task 完成时,worker 向 master 发送 message,其中包含这 R 个 temporary file 的 name。如果 master 收到一个已经 completed 的 map task 的 completion message,就忽略该 message;否则,它把这些 file name 记录进 master data structure。

Reduce task 完成时,reduce worker 会把 temporary output file atomic rename 成 final output file。如果同一个 reduce task 在多台 machine 上执行,就会对同一个 final output file 执行多次 rename。我们依赖底层 file system 提供的 atomic rename operation,保证最终 file-system state 只包含其中一次 reduce execution 产生的 data。

绝大多数 map 和 reduce operator 都是 deterministic 的;在这种情况下,语义等价于顺序执行,因此 programmer 很容易推理 program behavior。当 map 或 reduce operator 是 non-deterministic 时,我们提供较弱但仍然合理的 semantics。

如果 operator non-deterministic,某个 reduce task R1 的 output 等价于该 non-deterministic program 顺序执行时为 R1 产生的 output。但另一个 reduce task R2 的 output,可能对应另一次顺序执行时为 R2 产生的 output。

考虑 map task M 和 reduce task R1、R2。令 e(Ri) 表示实际 commit 的 Ri execution(恰好只有一个)。较弱语义的原因是:e(R1) 可能读取了 M 的某一次 execution 产生的 output,而 e(R2) 可能读取了 M 的另一次 execution 产生的 output。

3.4 Locality

在我们的 computing environment 中,network bandwidth 是相对稀缺的 resource。我们通过利用 input data 存储位置来节省 network bandwidth:这些 data 由 GFS [8] 管理,存放在构成 cluster 的 machine 的 local disk 上。

GFS 把每个 file 切成 64MB block,并把每个 block 的多个 copy(通常为 3 个)存放在不同 machine 上。MapReduce master 会考虑 input file 的 location information,尽量把 map task 调度到包含相应 input data replica 的 machine 上。如果做不到,则尝试把 map task 调度到 replica 附近,例如与存放 data 的 machine 位于同一个 network switch 的 worker machine 上。

当大型 MapReduce operation 使用 cluster 中相当大比例的 worker 时,大多数 input data 都能从 local 读取,不消耗 network bandwidth。

3.5 Task Granularity

如上所述,我们把 map phase 划分为 M 个 piece,把 reduce phase 划分为 R 个 piece。理想情况下,M 与 R 应该远大于 worker machine 数量。让每个 worker 执行很多不同 task,可以改善 dynamic load balancing,也能在 worker failure 时加快 recovery:worker 已完成的许多 map task 可以分散到其他所有 worker machine 上。

但在我们的 implementation 中,M 和 R 的大小存在 practical bound,因为 master 必须做 O(M + R) 个 scheduling decision,并在 memory 中保存如上所述的 O(M * R) state。不过,memory 使用的 constant factor 很小:state 中的 O(M * R) 部分,每个 map-task/reduce-task pair 大约只需要一个 byte data。

第 6 页:Task Granularity、Backup Tasks 与 Refinements

mapreduce p06

此外,user 经常会约束 R,因为每个 reduce task 的 output 最终都进入独立的 output file。实践中,我们倾向于这样选择 M:每个 task 大约处理 16–64MB input data(这样上面描述的 locality optimization 最有效);而 R 则选择为预期 worker machine 数量的一个小倍数。我们经常使用 M = 200,000、R = 5,000 的 MapReduce computation,并使用 2,000 台 worker machine。

3.6 Backup Tasks

延长 MapReduce operation 总耗时的一个常见原因是 straggler:在 computation 最后的少数 map 或 reduce task 中,某台 machine 异常慢地完成其中一个 task。

Straggler 可能由许多原因造成。例如,一台 disk 有问题的 machine 可能频繁发生可纠正的 error,使 read performance 从 30MB/s 降到 1MB/s。Cluster scheduling system 可能把其他 task 也调度到该 machine,导致它因 CPU、memory、local disk 或 network bandwidth 竞争而更慢。我们最近遇到的一个问题是 machine initialization code 中的 bug,它禁用了 processor cache;受影响 machine 上的 computation 速度下降了 100 倍以上。

我们提供了减轻 straggler 问题的通用 mechanism。当 MapReduce operation 接近完成时,master 会为剩余 in-progress task 调度 backup execution。只要 primary 或 backup execution 中任意一个完成,该 task 就被标记为 completed。我们对这个 mechanism 做过 tuning,使它通常只增加不超过几个百分点的 computational resource 使用量。

我们发现它可以显著降低大型 MapReduce operation 的完成时间。例如,第 5.3 节描述的 sort program,在禁用 backup task mechanism 后,完成时间增加了 44%。

4 Refinements

仅仅编写 Map 和 Reduce function 所提供的基本功能已经满足大多数需求,但我们发现一些 extension 很有用。本节描述这些 extension。

4.1 Partitioning Function

MapReduce user 指定所需的 reduce task/output file 数量 R。Data 使用 intermediate key 上的 partitioning function 在这些 task 间划分。系统提供一个使用 hashing 的默认 partitioning function,例如 hash(key) mod R,它通常能产生相当均衡的 partition。

但在一些情况下,按 key 的其他 function partition data 很有用。例如 output key 是 URL 时,我们希望同一个 host 的所有 entry 进入同一个 output file。为支持这种情况,MapReduce library user 可以提供 special partitioning function。比如,把 hash(Hostname(urlkey)) mod R 作为 partitioning function,就会让同一 host 的所有 URL 进入同一个 output file。

4.2 Ordering Guarantees

我们保证:在给定 partition 内,intermediate key/value pair 按 increasing key order 处理。这个 ordering guarantee 让每个 partition 很容易生成一个 sorted output file;当 output file format 需要支持按 key 的高效 random-access lookup,或者 user 希望 output data 已经排序时,这种能力很有用。

4.3 Combiner Function

在某些情况下,每个 map task 产生的 intermediate key 有大量重复,并且 user 指定的 Reduce function 同时满足 commutative 和 associative。第 2.1 节的 word-count example 就是很好的例子。由于 word frequency 往往服从 Zipf distribution,每个 map task 会产生数百或数千条 <the, 1> record。所有这些 count 都会通过 network 发送给单个 reduce task,再由 Reduce function 相加成为一个 number。

我们允许 user 指定 optional Combiner function,在 data 通过 network 发送之前做 partial merge。

Combiner function 在执行 map task 的每台 machine 上运行。通常,combiner 和 reduce function 使用同一份 code。Reduce function 与 combiner function 的唯一差别,是 MapReduce library 如何处理 function output:Reduce function 的 output 写入 final output file;Combiner function 的 output 写入将被发送给 reduce task 的 intermediate file。

Partial combining 能显著加速某些 MapReduce operation。Appendix A 包含一个使用 combiner 的例子。

第 7 页:Input/Output Types、Side Effects、Bad Records、Local Execution 与 Status

mapreduce p07

4.4 Input and Output Types

MapReduce library 支持以多种 format 读取 input data。例如,text mode input 把每行视作一个 key/value pair:key 是该行在 file 中的 offset,value 是该行内容。

另一个常见的 supported format 存储按 key 排序的 key/value pair sequence。每个 input type implementation 都知道如何把自身切成适合作为独立 map task 处理的 meaningful range(例如,text mode 的 range splitting 保证 split 只发生在 line boundary)。User 可以通过实现一个简单 reader interface,为新的 input type 增加支持,不过大多数 user 只使用少数预定义 input type。

Reader 不一定要提供从 file 读出的 data。例如,很容易定义一个从 database 读取 record 的 reader,或者从 memory-mapped data structure 读取 record 的 reader。

类似地,我们支持一组 output type,用于以不同 format 生成 data;user code 也很容易为新的 output type 增加支持。

4.5 Side-effects

在某些情况下,MapReduce user 发现让 map 或 reduce operator 产生 auxiliary file 作为额外 output 很方便。我们要求 application writer 让这类 side-effect 保持 atomic 和 idempotent。典型做法是先写入 temporary file,完全生成后再 atomic rename 该 file。

我们不支持由一个 task 产生的多个 output file 的 atomic two-phase commit。因此,如果 task 产生多个具有 cross-file consistency requirement 的 output file,它就应该是 deterministic 的。实践中,这个限制从未成为问题。

4.6 Skipping Bad Records

有时 user code 中的 bug 会让 Map 或 Reduce function 在某些 record 上 deterministic 地 crash,从而阻止 MapReduce operation 完成。通常的处理办法是修复 bug;但有时做不到,例如 bug 位于无法获得 source code 的 third-party library 中。此外,在对大型 data set 进行 statistical analysis 时,忽略少量 record 有时是可接受的。

我们提供一种 optional execution mode:MapReduce library 检测哪些 record 会导致 deterministic crash,并跳过这些 record,以便继续向前推进。

每个 worker process 安装一个 signal handler,捕获 segmentation violation 和 bus error。在调用 user 的 Map 或 Reduce operation 前,MapReduce library 把 argument 的 sequence number 存到 global variable 中。如果 user code 产生 signal,signal handler 就向 MapReduce master 发送一个包含 sequence number 的 “last gasp” UDP packet。当 master 在某条 record 上观察到多次 failure 后,它会在下一次重新执行对应 Map 或 Reduce task 时指示跳过该 record。

4.7 Local Execution

由于真实 computation 发生在 distributed system 中,往往涉及数千台 machine,且 work assignment 由 master 动态决定,因此 debug Map 或 Reduce function 可能很困难。为了便于 debugging、profiling 和 small-scale testing,我们开发了 MapReduce library 的另一种 implementation:在 local machine 上 sequentially 执行一个 MapReduce operation 的全部 work。

User 可以使用 control 把 computation 限制到特定 map task。User 以 special flag 启动 program,之后就可以方便地使用自己喜欢的 debugging 或 testing tool(例如 gdb)。

4.8 Status Information

Master 运行一个 internal HTTP server,并提供一组面向 human 的 status page。Status page 显示 computation progress,例如 completed task 数量、in-progress task 数量、input byte 数、intermediate data byte 数、output byte 数、processing rate 等。Page 还包含每个 task 生成的 standard error 和 standard output file 的 link。

User 可以用这些 data 预测 computation 还需要多长时间,以及是否需要为 computation 增加更多 resource。这些 page 也可以帮助发现 computation 何时显著慢于预期。

此外,top-level status page 显示哪些 worker failed,以及 failure 时它们正在处理哪些 map 和 reduce task。这些信息对尝试诊断 user code 中的 bug 很有用。

第 8 页:Counters、Performance、Grep 与 Sort 环境

mapreduce p08

4.9 Counters

MapReduce library 提供 counter facility,用于统计各种 event 的发生次数。例如,user code 可能想统计处理的 word 总数,或者被索引的 German document 数量。

使用这个 facility 时,user code 创建一个 named counter object,并在 Map 或 Reduce function 中适当地增加 counter。例如:

cpp
Counter* uppercase;
uppercase = GetCounter("uppercase");

map(String name, String contents):
  for each word w in contents:
    if (IsCapitalized(w)):
      uppercase->Increment();
    EmitIntermediate(w, "1");

每台 worker machine 的 counter value 会周期性传播给 master(piggyback 在 ping response 上)。Master 聚合成功 map 和 reduce task 的 counter value,并在 MapReduce operation 完成时将结果返回给 user code。当前 counter value 也显示在 master status page 上,human 可以观察正在运行的 computation progress。

聚合 counter value 时,master 会消除同一个 map 或 reduce task 重复执行的影响,以避免 double counting。Duplicate execution 可能来自 backup task,也可能来自 failure 导致的 task re-execution。

MapReduce library 会自动维护一些 counter value,例如已处理的 input key/value pair 数量和产生的 output key/value pair 数量。

User 发现 counter facility 对 sanity-check MapReduce operation 很有用。例如,在某些 operation 中,user code 可能希望确保产生的 output pair 数量恰好等于处理的 input pair 数量,或者希望检查已处理 German document 占全部 document 的比例是否处于可容忍范围内。

5 Performance

本节测量 MapReduce 在大型 machine cluster 上运行两个 computation 时的 performance。一个 computation 在约一 terabyte data 中查找某个 pattern;另一个 computation 对约一 terabyte data 做 sort。这两个 program 代表 MapReduce user 编写的大量 real program 中的两类:一类把 data 从一种 representation shuffle 成另一种 representation,另一类从大型 data set 中提取少量 interesting data。

5.1 Cluster Configuration

所有 program 都在一个约 1800 台 machine 的 cluster 上执行。每台 machine 有两个启用 Hyper-Threading 的 2GHz Intel Xeon processor、4GB memory、两块 160GB IDE disk 和一个 gigabit Ethernet link。Machine 排列成两层树状 switched network,root 处约有 100–200Gbps aggregate bandwidth。所有 machine 都位于同一 hosting facility,因此任意两台 machine 之间的 round-trip time 小于 1ms。

4GB memory 中约 1–1.5GB 被 cluster 中运行的其他 task 保留。Program 在一个周末下午执行,此时 CPU、disk 和 network 大多处于 idle。

5.2 Grep

grep program 扫描 10^10 条、每条 100 byte 的 record,寻找一个相对少见的三字符 pattern(该 pattern 出现在 92,337 条 record 中)。Input 被切成约 64MB piece(M = 15000),全部 output 放入一个 file(R = 1)。

Figure 2 展示 computation 随时间的 progress。Y-axis 表示扫描 input data 的速率。随着越来越多 machine 被分配给这个 MapReduce computation,速率逐步提升;当分配了 1764 个 worker 时,峰值超过 30GB/s。Map task 完成后,速率开始下降,并在 computation 开始约 80 秒后降到零。整个 computation 从开始到结束约耗时 150 秒,其中包含约一分钟的 startup overhead。Overhead 来自把 program 传播到所有 worker machine,以及与 GFS 交互、打开 1000 个 input file 并获取 locality optimization 所需 information 的延迟。

Figure 2:Data transfer rate over time

原图展示 grep 运行期间的 input scanning rate 随时间逐渐上升、达到峰值后因 map task 完成而下降的曲线;Y-axis 为 Input(MB/s),横轴为 Seconds。

第 9 页:Sort 性能与 Figure 3

mapreduce p09

5.3 Sort

sort program 对 10^10 条、每条 100 byte 的 record(约 1TB data)排序。该 program 以 TeraSort benchmark [10] 为模型。

Sorting program 的 user code 少于 50 行。一个三行的 Map function 从 text line 中提取 10-byte sorting key,并把 key 和原始 text line 作为 intermediate key/value pair 输出。我们使用内置的 Identity function 作为 Reduce operator;该 function 原样传递 intermediate key/value pair,作为 output key/value pair。

Final sorted output 写入一组 two-way replicated GFS file(也就是说,program output 实际写入 2TB)。和前面一样,input 被切成 64MB piece(M = 15000)。Sorted output 被 partition 成 4000 个 file(R = 4000)。Partitioning function 使用 key 的初始 byte,把 key 分配到 R 个 piece 中。

这个 benchmark 的 partitioning function 内置了 key distribution knowledge。在通用 sorting program 中,我们会加入一个 pre-pass MapReduce operation,收集 key sample,并使用 sampled key 的 distribution 计算最终 sorting pass 的 split point。

Figure 3(a) 展示 sort program 的 normal execution progress。左上图显示 input read rate。峰值约为 13GB/s,并很快下降,因为所有 map task 在 200 秒前已经完成。请注意,input rate 低于 grep;这是因为 sort map task 大约一半时间和 I/O bandwidth 用于把 intermediate output 写入 local disk,而 grep 对应的 intermediate output 大小可以忽略。

左中图显示 map task 向 reduce task 发送 data 的 network rate。这个 shuffle 从第一个 map task 完成时就开始。图中的第一个 hump 对应第一批约 1700 个 reduce task(整个 MapReduce 分配了约 1700 台 machine,每台 machine 同时最多执行一个 reduce task)。Computation 开始约 300 秒后,这批 reduce task 中的一些已经完成,于是开始为剩余 reduce task shuffle data。约 600 秒时所有 shuffle 完成。

左下图显示 reduce task 把 sorted data 写入 final output file 的 rate。第一轮 shuffle 结束和 write 开始之间存在延迟,因为 machine 正忙于排序 intermediate data。之后 write 以约 2–4GB/s 的速率持续一段时间,约在 computation 开始 850 秒时全部完成。包括 startup overhead 在内,整个 computation 用时 891 秒。这与当前报道的 TeraSort benchmark 最好结果 1057 秒相近。

需要注意几点:由于 locality optimization,大多数 data 从 local disk 读取并绕过 bandwidth 受限的 network,因此 input rate 高于 shuffle rate 和 output rate。由于 output phase 写入 sorted data 的两个 copy,shuffle rate 高于 output rate;我们为 reliability 和 availability 生成两个 replica,这是底层 file system 提供的机制。如果底层 file system 使用 erasure coding [14] 而不是 replication,write data 所需的 network bandwidth 会减少。

Figure 3:不同 sort execution 的 data transfer rate

原图给出三组时间曲线:(a)Normal execution;(b)No backup tasks;(c)200 tasks killed。每组都分别展示 Input、Shuffle、Output 三条 rate 曲线,并以 Done 标记完成时间。

第 10 页:Backup Tasks、Machine Failures、Experience 与生产统计

mapreduce p10

5.4 Effect of Backup Tasks

Figure 3(b) 展示禁用 backup task 后的 sort execution。其 execution flow 与 Figure 3(a) 类似,但末尾出现一个很长的 tail,几乎没有 write activity。960 秒后,除了 5 个 reduce task 外其余都已经完成;但最后几个 straggler 又过了 300 秒才结束。整个 computation 用时 1283 秒,比启用 backup task 时增加 44%。

5.5 Machine Failures

Figure 3(c) 展示一种 sort execution:在 computation 开始几分钟后,我们有意杀掉 1746 个 worker process 中的 200 个。底层 cluster scheduler 立即在这些 machine 上重新启动新的 worker process(因为只杀掉了 process,machine 本身仍然正常工作)。

Worker death 表现为负的 input rate,因为一些此前已完成的 map work 消失了(对应的 map worker 被杀掉),需要重新执行。Map work 的 re-execution 很快完成。包括 startup overhead 在内,整个 computation 在 933 秒后结束,比 normal execution 只增加 5%。

6 Experience

我们在 2003 年 2 月编写了 MapReduce library 的第一个版本,并在 2003 年 8 月做了重大 enhancement,包括 locality optimization、map task 在 worker machine 间执行的 dynamic load balancing 等。从那时起,我们惊讶于 MapReduce library 对 Google 内部各种问题的广泛适用性。它已经用于多个领域,包括:

  • large-scale machine learning problem;
  • Google News 和 Froogle 产品的 clustering problem;
  • 提取用于 popular-query report 的 data(例如 Google Zeitgeist);
  • 提取 web page property,用于新 experiment 和 product(例如,从大型 web page corpus 中提取 geographical location,以支持 localized search);
  • large-scale graph computation。

Figure 4:MapReduce instance 随时间的变化

原图显示 primary source-code management system 中独立 MapReduce program 数量随时间增长:从 2003 年初的 0 个,增长到 2004 年 9 月底接近 900 个。

Table 1:2004 年 8 月运行的 MapReduce job

指标数值
Number of jobs29,423
Average job completion time634 secs
Machine days used79,186 days
Input data read3,288 TB
Intermediate data produced758 TB
Output data written193 TB
Average worker machines per job157
Average worker deaths per job1.2
Average map tasks per job3,351
Average reduce tasks per job55
Unique map implementations395
Unique reduce implementations269
Unique map/reduce combinations426

MapReduce 之所以成功,是因为它让 programmer 可以编写一个简单 program,并在半小时内让它高效运行于一千台 machine 上,大幅加快 development 和 prototyping cycle。此外,它让没有 distributed 或 parallel system 经验的 programmer 也能方便地使用大量 resource。

每个 job 结束时,MapReduce library 会记录该 job 使用的 computational resource 统计。在 Table 1 中,我们展示 2004 年 8 月 Google 上运行的一部分 MapReduce job 的统计。

mapreduce p11

6.1 Large-Scale Indexing

MapReduce 到目前为止最重要的用途之一,是完整重写 production indexing system;该 system 生成 Google web search service 使用的 data structure。

Indexing system 的 input 是 crawling system 获取的大量 document,存储为一组 GFS file。这些 document 的 raw content 超过 20TB。Indexing process 由 5–10 个 MapReduce operation 串联组成。

与旧版本 indexing system 中的 ad-hoc distributed pass 相比,使用 MapReduce 带来了如下收益:

  • Indexing code 更简单、更小、更容易理解:处理 fault tolerance、distribution 和 parallelization 的 code 被隐藏在 MapReduce library 中。例如,某一阶段的 computation 从约 3800 行 C++ code 减少到使用 MapReduce 时的约 700 行。
  • Performance 足够好:可以保持概念上不相关的 computation 相互分离,而不是为了避免对 data 的额外 pass 把它们混在一起。因此修改 indexing process 很容易。例如,旧 indexing system 中需要几个月的一个 change,在新 system 中只需几天即可实现。
  • Operation 更容易:machine failure、slow machine 和 network hiccup 引起的大多数问题,都会由 MapReduce library 自动处理而不需要 operator intervention。此外,只需向 indexing cluster 添加新 machine,就很容易提高 indexing process 的 performance。

许多 system 提供过受限的 programming model,并利用这些限制自动 parallelize computation。例如,利用 parallel prefix computation,可以在 N 个 processor 上以 log N 时间对 N element array 的所有 prefix 计算 associative function [6, 9, 13]。MapReduce 可以看作基于我们对大型 real-world computation 的经验,对这些 model 做出的简化和提炼。更重要的是,我们提供了一个能扩展到数千个 processor 的 fault-tolerant implementation;相比之下,大多数 parallel-processing system 只在更小的规模上实现,并把 machine failure 处理细节留给 programmer。

Bulk Synchronous Programming [17] 和一些 MPI primitive [11] 提供更高层 abstraction,让 programmer 更容易编写 parallel program。MapReduce 与这些 system 的一个关键区别是:MapReduce 利用受限 programming model 自动 parallelize user program,并提供 transparent fault-tolerance。

我们的 locality optimization 受到 active disk [12, 15] 等 technique 的启发:把 computation 推近 local disk 所在的 processing element,以减少跨 I/O subsystem 或 network 发送的 data。我们运行在 commodity processor 上,每个 processor 直接连接少数 disk,而不是直接运行在 disk controller processor 上;但整体方法相似。

我们的 backup task mechanism 类似 Charlotte System [3] 使用的 eager scheduling mechanism。简单 eager scheduling 的一个缺点是:如果某个 task 反复导致 failure,整个 computation 就无法完成。我们用 skipping bad record mechanism 解决了其中一部分情况。

MapReduce implementation 依赖一个内部 cluster management system,负责在大型共享 machine 集合上分发和运行 user task。虽然这不是本文重点,但该 cluster management system 在思想上类似 Condor [16] 等其他 system。

MapReduce library 中的 sorting facility 在 operation 上类似 NOW-Sort [1]。Source machine(map worker)把待排序 data partition 后发送给 R 个 reduce worker。每个 reduce worker 在 local 上排序自己的 data(如果可能则在 memory 中完成)。当然,NOW-Sort 没有 MapReduce library 中 user-definable Map 和 Reduce function,因此适用范围不同。

River [2] 提供了一种 programming model:process 通过 distributed queue 发送 data 彼此通信。和 MapReduce 一样,River 试图在 heterogeneous hardware 或 system perturbation 引入的 non-uniformity 存在时,仍提供良好的 average-case performance。River 通过谨慎调度 disk 和 network transfer,使 completion time 平衡。

MapReduce 采用不同方法:通过限制 programming model,MapReduce framework 可以把 problem 划分成大量 fine-grained task。这些 task 被动态调度到可用 worker 上,因此更快的 worker 可以处理更多 task。受限 programming model 还允许我们在 job 接近结束时 schedule task 的 redundant execution,从而显著缩短 slow 或 stuck worker 存在时的 completion time。

第 12 页:Related Work、Conclusions 与 Appendix 引入

mapreduce p12

BAD-FS [5] 与 MapReduce 使用非常不同的 programming model,并且不像 MapReduce 那样面向 wide-area network 上的 job execution。不过,两者有两个 fundamental similarity:(1)都使用 redundant execution 来恢复由 failure 导致的数据丢失;(2)都使用 locality-aware scheduling,减少跨拥塞 network link 发送的 data。

TACC [7] 是一个用于简化 highly-available networked service 构建的 system。和 MapReduce 一样,它把 re-execution 作为实现 fault-tolerance 的 mechanism。

8 Conclusions

MapReduce programming model 已在 Google 内部成功用于许多不同目的。我们认为这种成功有几个原因。第一,即使 programmer 没有 parallel 和 distributed system 经验,该 model 也很容易使用,因为它隐藏了 parallelization、fault-tolerance、locality optimization 和 load balancing 的 detail。第二,许多不同问题都很容易表达为 MapReduce computation。例如,MapReduce 被用于生成 Google production web search service 的 data、sort、data mining、machine learning 以及许多其他 system。第三,我们开发了能够扩展到大型 machine cluster 的 MapReduce implementation,这些 cluster 包含数千台 machine。该 implementation 能够高效利用 machine resource,因此适合 Google 遇到的许多大型 computational problem。

我们从这项工作中学到几件事。第一,限制 programming model 可以让 computation 很容易 parallelize 和 distribute,也很容易使其具有 fault-tolerance。第二,network bandwidth 是稀缺 resource,因此 system 中许多 optimization 都针对减少跨 network 发送的 data:locality optimization 让我们可以从 local disk 读取 data;把 intermediate data 的单个 copy 写入 local disk 可以节省 network bandwidth。第三,redundant execution 可以降低 slow machine 的影响,并处理 machine failure 和 data loss。

Acknowledgements

Josh Levenberg 在根据自己使用 MapReduce 的经验和其他人的 enhancement 建议,修订并扩展 user-level MapReduce API 方面发挥了重要作用。MapReduce 从 Google File System [8] 读取 input,并向其写入 output。感谢 Mohit Aron、Howard Gobioff、Markus Gutschke、David Kramer、Shun-Tak Leung 和 Josh Redstone 对 GFS 开发所做的工作。感谢 Percy Liang 和 Olcan Sercinoglu 对 MapReduce 所使用的 cluster management system 的开发工作。Mike Burrows、Wilson Hsieh、Josh Levenberg、Sharon Perl、Rob Pike 和 Debby Wallach 对本文早期 draft 提供了有帮助的 comment。匿名 OSDI reviewer 和 shepherd Eric Brewer 对本文可改进之处提供了许多有用建议。最后,感谢 Google engineering organization 内所有 MapReduce user 提供的 feedback、建议和 bug report。

第 13 页:References 与 Appendix A 完整示例

mapreduce p13

References

  1. Andrea C. Arpaci-Dusseau、Remzi H. Arpaci-Dusseau、David E. Culler、Joseph M. Hellerstein、David A. Patterson. High-performance sorting on networks of workstations. Proc. of SIGMOD, 1997。
  2. Remzi H. Arpaci-Dusseau、Eric Anderson、Noah Treuhaft、David E. Culler、Joseph M. Hellerstein、David Patterson、Kathy Yelick. Cluster I/O with River: Making the fast case common. IOPADS ’99, 1999, pp. 10–22。
  3. Arash Baratloo、Mehmet Karaul、Zvi Kedem、Peter Wyckoff. Charlotte: Metacomputing on the web. 9th International Conference on Parallel and Distributed Computing Systems, 1996。
  4. Luiz A. Barroso、Jeffrey Dean、Urs Hölzle. Web search for a planet: The Google cluster architecture. IEEE Micro 23(2), 2003, pp. 22–28。
  5. John Bent、Douglas Thain、Andrea C. Arpaci-Dusseau、Remzi H. Arpaci-Dusseau、Miron Livny. Explicit control in a batch-aware distributed file system. 1st USENIX NSDI, 2004。
  6. Guy E. Blelloch. Scans as primitive parallel operations. IEEE Transactions on Computers C-38(11), 1989。
  7. Armando Fox、Steven D. Gribble、Yatin Chawathe、Eric A. Brewer、Paul Gauthier. Cluster-based scalable network services. 16th ACM SOSP, 1997, pp. 78–91。
  8. Sanjay Ghemawat、Howard Gobioff、Shun-Tak Leung. The Google file system. 19th Symposium on Operating Systems Principles, 2003, pp. 29–43。
  9. S. Gorlatch. Systematic efficient parallelization of scan and other list homomorphisms. In Euro-Par ’96, LNCS 1124, pp. 401–408, Springer-Verlag。
  10. Jim Gray. Sort benchmark home page。
  11. William Gropp、Ewing Lusk、Anthony Skjellum. Using MPI: Portable Parallel Programming with the Message-Passing Interface. MIT Press, 1999。
  12. L. Huston、R. Sukthankar、R. Wickremesinghe、M. Satyanarayanan、G. R. Ganger、E. Riedel、A. Ailamaki. Diamond: A storage architecture for early discard in interactive search. USENIX FAST, 2004。
  13. Richard E. Ladner、Michael J. Fischer. Parallel prefix computation. Journal of the ACM 27(4), 1980, pp. 831–838。
  14. Michael O. Rabin. Efficient dispersal of information for security, load balancing and fault tolerance. Journal of the ACM 36(2), 1989, pp. 335–348。
  15. Erik Riedel、Christos Faloutsos、Garth A. Gibson、David Nagle. Active disks for large-scale data processing. IEEE Computer, 2001, pp. 68–74。
  16. Douglas Thain、Todd Tannenbaum、Miron Livny. Distributed computing in practice: The Condor experience. Concurrency and Computation: Practice and Experience, 2004。
  17. L. G. Valiant. A bridging model for parallel computation. Communications of the ACM 33(8), 1997, pp. 103–111。
  18. Jim Wyllie. Spsort: How to sort a terabyte quickly。

Appendix A:Word Frequency

本节给出一个对命令行指定的一组 input file 统计每个 unique word 出现次数的 program。

cpp
#include "mapreduce/mapreduce.h"

// User’s map function
class WordCounter : public Mapper {
public:
  virtual void Map(const MapInput& input) {
    const string& text = input.value();
    const int n = text.size();
    for (int i = 0; i < n; ) {
      // Skip past leading whitespace
      while ((i < n) && isspace(text[i]))
        i++;
      // Find word end
      int start = i;
      while ((i < n) && !isspace(text[i]))
        i++;
      if (start < i)
        Emit(text.substr(start,i-start),"1");
    }
  }
};
REGISTER_MAPPER(WordCounter);

// User’s reduce function
class Adder : public Reducer {
  virtual void Reduce(ReduceInput* input) {
    // Iterate over all entries with the same key and add the values
    int64 value = 0;
    while (!input->done()) {
      value += StringToInt(input->value());
      input->NextValue();
    }
    // Emit sum for input->key()
    Emit(IntToString(value));
  }
};
REGISTER_REDUCER(Adder);

int main(int argc, char** argv) {
  ParseCommandLineFlags(argc, argv);
  MapReduceSpecification spec;
  // Store list of input files into "spec"
  for (int i = 1; i < argc; i++) {
    MapReduceInput* input = spec.add_input();
    input->set_format("text");
    input->set_filepattern(argv[i]);
    input->set_mapper_class("WordCounter");
  }
  // Specify the output files:
  // /gfs/test/freq-00000-of-00100 ...
  MapReduceOutput* out = spec.output();
  out->set_filebase("/gfs/test/freq");
  out->set_num_tasks(100);
  out->set_format("text");
  out->set_reducer_class("Adder");
  // Optional: do partial sums within map tasks to save network bandwidth
  out->set_combiner_class("Adder");
  // Tuning parameters: use at most 2000 machines and 100 MB of memory per task
  spec.set_machines(2000);
  spec.set_map_megabytes(100);
  spec.set_reduce_megabytes(100);
  // Now run it
  MapReduceResult result;
  if (!MapReduce(spec, &result)) abort();
  // Done: result contains counters, time taken, machines used, etc.
  return 0;
}

机制索引

机制本文位置关键判断
Map/Reduce abstraction第 1–2 页用受限 functional interface 表达大量 batch computation
Shuffle第 3–4 页map output 按 partition 写 local disk,reduce worker remote read 并排序
Task state第 4 页master 记录 idle/in-progress/completed 与 worker identity
Re-execution第 4–5 页worker failure 通过 reset task 并重新调度恢复
Atomic commit第 5 页temporary file + atomic rename,避免 duplicate execution 污染 final output
Locality第 5 页将 map task 调度到 GFS input replica 所在 machine 或附近
Task granularity第 5–6 页M/R 远大于 worker 数量,改善 load balancing 和 recovery
Backup task第 6 页speculative duplicate execution 缩短 straggler 尾部
Combiner第 6 页map 本地先做 partial aggregation,减少 shuffle traffic
Bad-record skipping第 7 页对 deterministic crash record 可选择跳过,以继续推进 job
Counters第 8 页对 input/output 数量等运行时行为做 sanity checking
生产经验第 10–12 页简洁 API、自动 failure handling 和资源扩展推动 adoption

本篇验收

  • 页面覆盖:13/13 个 PDF 页面均已保留原图并按原顺序翻译。
  • 图表覆盖:保留 Figure 1–4、Table 1、Figure 2/3 的性能曲线、伪代码、C++ counter 示例和 Appendix A 完整 C++ program。
  • 机制覆盖:programming model、word count、examples、execution overview、master state、worker/master failure、failure semantics、locality、task granularity、backup tasks、partitioning、ordering、combiner、input/output type、side-effects、bad records、local execution、status、counters、performance、experience、indexing、related work 和 conclusions 均已覆盖。
  • 翻译策略:遵循逐页、逐段顺序;MapReduce 生态中的约定俗成术语保留 English,不强行直译;原文页面图作为版式与图片位置的最终依据。

参考资料

← 返回列表
← 上一篇 论文:Bigtable:A Distributed Storage System for Structured Data 下一篇 → 论文:ZooKeeper:Wait-free Coordination for Internet-scale Systems

评论 (0)

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