6.824 paper MapReduce: Simplified Data Processing on Large Clusters

本文详细介绍了MapReduce的实现原理,包括执行概述、数据结构、容错机制以及实现细节。Map任务通过分区输入数据并在多台机器上并行执行,Reduce任务通过分区函数分配。容错机制包括处理worker失败和master失败的情况,确保数据处理的可靠性。此外,文中还讨论了局部性、任务粒度、备份任务等优化措施。

本文关于原理部分的内容主要在第三第四节:

3 Implementation

3.1 Execution Overview

The Map invocations are distributed across multiple machines by automatically partitioning the input data into a set of M splits. The input splits can be pro-cessed in parallel by different machines. Reduce invoca-tions are distributed by partitioning the intermediate key space into R pieces using a partitioning function (e.g.,hash(key) mod R). The number of partitions (R) and the partitioning function are specified by the user.

map:

将输入分为M份(依据什么分?),对应到M台机器上,然后分别调用map函数。他们在不同机器上是并行执行的

reduce:

将map的输出也就是中间键值对用一个partition函数(如哈希取modR)分成R个piece,然后分别调用reduce

 

上图:

Figure 1 shows the overall flow of a MapReduce op- eration in our implementation. When the user program calls the MapReduce function, the following sequence of actions occurs (the numbered labels in Figure 1 corre-spond to the numbers in the list below):

一次MR的流程是:

1. The MapReduce library in the user program first splits the input files into M pieces of typically 16 megabytes to 64 megabytes (MB) per piece (con-trollable by the user via an optional parameter). It then starts up many copies of the program on a clus-ter of machines.

1.MR将输入分为M份(每份的大小由用户指定),然后在集群上运行多个该程序(用户编写的应用程序和MR框架的集合?)的copy(类似集群里的每台机器运行一个该程序的实例)

2. One of the copies of the program is special – the master. The rest are workers that are assigned work by the master. There are M map tasks and R reduce tasks to assign. The master picks idle workers and assigns each one a map task or a reduce task.

2.这些实例中有一个是特殊的,是master,其余的是worker,master给worker分配任务(所以实际上master和worker对应的程序是相同的,只是他们的身份不同,从而行为也不同?)

共有M个Map任务,R个Reduce任务,master从空闲的worker中挑出并分配map或者reduce任务

3. A worker who is assigned a map task reads the contents of the corresponding input split. It parses key/value pairs out of the input data and passes each pair to the user-defined Map function. The interme-diate key/value pairs produced by the Map function are buffered in memory.

3.被分配map任务的worker,首先从对应input split中读取输入,从输入中解析出键值对,然后调用map函数。输出的中间键值对缓存在内存里(

4. Periodically, the buffered pairs are written to local disk, partitioned into R regions by the partitioning function. The locations of these buffered pairs on the local disk are passed back to the master, who is responsible for forwarding these locations to the reduce workers.

4.阶段性的,缓存的键值对保存到本地磁盘,通过partition函数分为R piece。对应的在本地磁盘上的路径,被传给master,master负责将这些路径传给对应的reduce worker。

5. When a reduce worker is notified by the master about these locations, it uses remote procedure calls to read the buffered data from the local disks of the map workers. When a reduce worker has read all in-termediate data, it sorts it by the intermediate keys so that all occurrences of the same key are grouped together. The sorting is needed because typically many different keys map to the same reduce task. If the amount of intermediate data is too large to fit in memory, an external sort is used.

5.当reduce worker从master得知输入数据的路径信息后,使用RPC从之前的map worker的本地磁盘读出来。当他将自己的输入数据读取完成后,首先按照key排序,以便将key相同的中间键值对聚集起来,因为有不同的key通过partition函数映射到了同一个reduce worker,所以需要排序。

6. The reduce worker iterates over the sorted interme-diate data and for each unique intermediate key en-countered, it passes the key and the corresponding set of intermediate values to the user’s Reduce func-tion. The output of the Reduce function is appended to a final output file for this reduce partition.

6.reduce worker对排序后的中间值进行遍历,将相同key的键值对作为一次reduce函数的输入,调用reduce函数。reduce函数的输出被追加到a final output file for this reduce partition(?

7. When all map tasks and reduce tasks have been completed, the master wakes up the user program.At this point, the MapReduce call in the user pro-gram returns back to the user code.

7.所有的map和reduce任务完成后,本次MR结束,返回

一次MR成功完成后,输出在R个输出文件里(注意有R个reduce调用)。一般,用户不会直接将这R个文件merge起来,而是将他们作为另一个MR的输入

3.2 Master Data Structures

The master keeps several data structures. For each map task and reduce task, it stores the state (idle, in-progress,or completed), and the identity of the worker machine (for non-idle tasks).

master维护了一系列数据结构。对每个map和reduce任务,他保存了任务的状态(空闲,进行中,已完成。空闲就是指还没执行吧?),以及对应worker的身份(如果该任务非空闲。已完成的呢?

The master is the conduit through which the location of intermediate file regions is propagated from map tasks to reduce tasks. Therefore, for each completed map task,the master stores the locations and sizes of the R inter-mediate file regions produced by the map task. Updates to this location and size information are received as map tasks are completed. The information is pushed incre-mentally to workers that have in-progress reduce tasks.

中间文件的路径信息通过master从map task传到reduce task。master为每个完成的map任务保存了路径信息以及该map任务产生的中间文件对应到R个region里相应的size(比如产生了3个文件,总共有三个region,刚好产生的中间文件通过partition函数分别对应到三个region,那么size就都是1)当map任务完成时,对路径信息以及size信息的更新就收到了()。这些信息被逐渐的push到正在处理reduce任务的worker

↑ 这个在注意一下,对应到具体实现里应该是怎样的

3.3 Fault Tolerance

因为MR的主要用途是大型计算,那么自然需要妥善处理machine failure的情况

Worker Failure

The master pings every worker periodica

内容概要:文章以“智能网页数据标注工具”为例,深入探讨了谷歌浏览器扩展在毕业设计中的实战应用。通过开发具备实体识别、情感分类等功能的浏览器扩展,学生能够融合前端开发、自然语言处理(NLP)、本地存储与模型推理等技术,实现高效的网页数据标注系统。文中详细解析了扩展的技术架构,涵盖Manifest V3配置、内容脚本与Service Worker协作、TensorFlow.js模型在浏览器端的轻量化部署与推理流程,并提供了核心代码实现,包括文本选择、标注工具栏动态生成、高亮显示及模型预测功能。同时展望了多模态标注、主动学习与边缘计算协同等未来发展方向。; 适合人群:具备前端开发基础、熟悉JavaScript和浏览器机制,有一定AI模型应用经验的计算机相关专业本科生或研究生,尤其适合将浏览器扩展与人工智能结合进行毕业设计的学生。; 使用场景及目标:①掌握浏览器扩展开发全流程,理解内容脚本、Service Worker与弹出页的通信机制;②实现在浏览器端运行轻量级AI模型(如NER、情感分析)的技术方案;③构建可用于真实场景的数据标注工具,提升标注效率并探索主动学习、协同标注等智能化功能。; 阅读建议:建议结合代码实例搭建开发环境,逐步实现标注功能并集成本地模型推理。重点关注模型轻量化、内存管理与DOM操作的稳定性,在实践中理解浏览器扩展的安全机制与性能优化策略。
基于Gin+GORM+Casbin+Vue.js的权限管理系统是一个采用前后端分离架构的企业级权限管理解决方案,专为软件工程和计算机科学专业的毕业设计项目开发。该系统基于Go语言构建后端服务,结合Vue.js前端框架,实现了完整的权限控制和管理功能,适用于各类需要精细化权限管理的应用场景。 系统后端采用Gin作为Web框架,提供高性能的HTTP服务;使用GORM作为ORM框架,简化数据库操作;集成Casbin实现灵活的权限控制模型。前端基于vue-element-admin模板开发,提供现代化的用户界面和交互体验。系统采用分层架构和模块化设计,确保代码的可维护性和可扩展性。 主要功能包括用户管理、角色管理、权限管理、菜单管理、操作日志等核心模块。用户管理模块支持用户信息的增删改查和状态管理;角色管理模块允许定义不同角色并分配相应权限;权限管理模块基于Casbin实现细粒度的访问控制;菜单管理模块动态生成前端导航菜单;操作日志模块记录系统关键操作,便于审计和追踪。 技术栈方面,后端使用Go语言开发,结合Gin、GORM、Casbin等成熟框架;前端使用Vue.js、Element UI等现代前端技术;数据库支持MySQL、PostgreSQL等主流关系型数据库;采用RESTful API设计规范,确保前后端通信的标准化。系统还应用了单例模式、工厂模式、依赖注入等设计模式,提升代码质量和可测试性。 该权限管理系统适用于企业管理系统、内部办公平台、多租户SaaS应用等需要复杂权限控制的场景。作为毕业设计项目,它提供了完整的源码和论文文档,帮助学生深入理解前后端分离架构、权限控制原理、现代Web开发技术等关键知识点。系统设计规范,代码结构清晰,注释完整,非常适合作为计算机相关专业的毕业设计参考或实际项目开发的基础框架。 资源包含完整的系统源码、数据库设计文档、部署说明和毕
MapReduce 实现运行在大型 PC 机集群上,具有良好的扩展性,能在数千台机器上处理若干 TB 的数据。其为程序员隐藏了绝大多数系统层面的处理细节,提供了统一的计算框架以及抽象和高层的编程接口与框架。 程序员使用这一系统较为轻松,只需关心应用层的具体计算问题,编写少量处理应用本身计算问题的程序代码,而如何具体完成并行计算任务所相关的诸多系统层细节被交给计算框架处理。目前已有数以百计的 MapReduce 程序实现,每天有上千个 MapReduce 作业运行在 Google 的集群上,体现了其在大型集群数据处理方面的实用性和高效性 [^1][^3]。 ```python # 这里以一个简单的伪代码示例说明 MapReduce 思想 # 模拟 Map 函数 def map_function(data): # 对输入数据进行处理,这里简单返回数据的键值对 return [(word, 1) for word in data.split()] # 模拟 Reduce 函数 def reduce_function(key, values): # 对相同键的值进行聚合 return key, sum(values) # 模拟输入数据 input_data = "hello world hello python" # 进行 Map 操作 mapped_data = [] for item in map_function(input_data): mapped_data.append(item) # 对 Map 结果进行分组 grouped_data = {} for key, value in mapped_data: if key not in grouped_data: grouped_data[key] = [] grouped_data[key].append(value) # 进行 Reduce 操作 reduced_data = [] for key, values in grouped_data.items(): result = reduce_function(key, values) reduced_data.append(result) print(reduced_data) ```
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值