ucb关于spark的论文,对spark中核心组件RDD最原始、本质的理解,没有比这个更好的资料了。必读。
Abstract
RDDs provide a restricted form of shared memory, based on coarse grained transformations rather than fine-grained updates to shared state.
RDD 提供的是粗粒度的更新操作。其实是指RDD是不可改变的,如果要更新数据,需要创建一个新的RDD代替。但这并不意味着更新的操作代价就非常大,因为你可以把大数据集拆分成多个小的RDD,大数据集的部分更新,其实对应着其中的某(几)个RDD更新。
Introducction
*** offer an interface based on fine-grained updates to mutable state (e.g., cells in a table). With this interface, the only ways to provide fault tolerance are to replicate the data across machines or to log updates across machines. Both approaches are expensive for data-intensive workloads, as they require copying large amounts of data over the cluster network, whose bandwidth is far lower than that of RAM, and they incur substantial storage overhead.
文中指出,使用细粒度的更新(平时见到的更新内存和文件,都是细粒度更新,因为允许更新部分内容),保证容错性的唯一方法是将数据或数据的log复制到其它机器上。
RDDs provide an interface based on coarse-grained transformations (e.g., map,filter and join) that apply the same operation to many data items. This allows them to efficiently provide fault tolerance by logging the transformations used to build a dataset (its lineage) rather than the actual data.
RDD使用粗粒度更新(不可变性质),这样它就可以通过记录数据的转换过程(血统lineage)来做容错(,而不需要备份真正的更新后的数据)。文中后面指出,RDD的lingage一般不超过10k大小。
2 Resilient Distributed Datasets(RDDs)
2.1 RDD Abstraction
Formally, an RDD is a read-only, partitioned collection of records. RDDs can only be created through deterministic operations on either (1) data in stable storage or (2) other RDDs. We call these operations transformations to differentiate them from other perations on RDDs. Examples of transformations include map, filter, and join
RDD是只读、分片的数据集,它只能通过确切的方法在两个源上创建:1)可靠存储中的数据;2)其他RDD。 RDD支持很多操作,为了特别区别其中这些创建RDD的操作,将它们称为transformation,像map、filter、join
in essence, a program cannot reference an RDD that it cannot reconstruct after a failure
程序不能引用已经失效的RDD。这是为了保证所有的RDD都“师出有名”。
2.2 Spark Programming Interface
each dataset is represented as an object and transformations are invoked using methods on these objects.
每个数据集都是一个对象,而transformation是对象的一个方法
They can then use these RDDs in actions, which are operations that return a value to the application or export data to a storage system.
RDD起源于可靠存储设备,然后可以生成其他的RDD。RDD还可以使用action来返回一个值给用户或者将数据存储到存储设备(action操作不会产生新的RDD,可以认为是RDD的输出,也可以认为是lineage的‘叶子节点‘或’末端‘)
Spark computes RDDs lazily the first time they are used in an action, so that it can pipeline transformations.
Spark会将RDD的实例化推迟到真正使用到action的时候,这样中间环节的多个RDD转换就可能进行串行化转换操作。(这是spark性能高的另一个主要原因)
In addition, programmers can call a persist method to indicate which RDDs they want to reuse in future operations
程序员可以指定哪个RDD需要重用,将他们保留在内存/磁盘中。(后续版本会致力于自动做这个决定,因为这是个艰难的决定。。)
3 Spark Programming Interface
To use Spark, developers write a
driver program that connects to a cluster of
workers, as shown in Figure 2. The driver defines one or more RDDs and invokes actions on them.
Spark code on the driver also tracks the RDDs’ lineage. The workers are long-lived rocesses that can store RDD partitions in RAM across operations.
这短短的一小段,就将spark的工作原理描述得很清晰了(此时的spark仅有14k的源码!!)这里吧driver、worker的概念、关系以及运行方式都介绍了。特别注意的一点:RDD的血统(lingeage)是保存子啊driver中的。
RDDs themselves are statically typed objects parametrized by an element type. For example, RDD[Int] is an RDD of integers. However, most of our examples omit types since Scala supports type inference.
RDD支持的操作:(特别注意入参合出参的关系和形式)
4. Representing RDDs
In a nutshell, we propose representing each RDD through a common interface that exposes five pieces of information: a set of partitions, which are atomic pieces of the dataset; a set of dependencies on parent RDDs; a function for computing the dataset based on its parents; and metadata about its partitioning scheme and data placement.
RDD由5个部分组成:
- 数据分片,作为数据集的原子分片;
- 与父节点的依赖集合;
- 一个指明它是怎么从父节点创建而来的函数;
- 数据分片的元数据,关于分片模式的。
- 指明RDD怎么存储的数据
下面是RDD的两个重要概念: 窄依赖和宽依赖
We found it both sufficient and useful to classify dependencies into two types: narrow dependencies, where each partition of the parent RDD is used by at most one partition of the child RDD, wide dependencies, where multiple child partitions may depend on it. For example, map leads to a narrow dependency, while join leads to to wide dependencies
窄依赖:父节点的每个分片数据,最多只被一个子节点依赖;
宽依赖: 父节点的每个分片,被多个子节点依赖;
This distinction is useful for two reasons. First, narrow dependencies allow for pipelined execution on one cluster node, which can compute all the parent partitions. For example, one can apply a map followed by a filter on an element-by-element basis. In contrast, wide dependencies require data from all parent partitions to be available and to be shuffled across the nodes using a apReducelike operation. Second, recovery after a node failure is more efficient with a narrow dependency, as only the lost parent partitions need to be recomputed, and they can be recomputed in parallel on different nodes. In contrast, in a lineage graph with wide dependencies, a single failed node might cause the loss of some partition from all the ancestors of an RDD, requiring a complete re-execution
窄依赖的优点:
- 串行化允许多个RDD操作在一个机器上串行化处理(因为它不依赖于其他RDD),可以避免RDD传输的网络开销,以及各个操作之间的同步等待;
- 当一个RDD失效后,仅需要获取它的父节点,执行transformation重新生成这个RDD。
This common interface for RDDs made it possible to implement most transformations in Spark in less than 20 lines of code
5 Implementation
We have implemented Spark in about 14,000 lines of Scala.
5.1 Job Scheduling
Whenever a user runs an action (e.g., count or save) on an RDD, the scheduler examines that RDD’s lineage graph to build a DAG
of stages to execute, as illustrated in Figure 5. Each stage contains as many pipelined transformations with narrow dependencies as possible. The boundaries of the stages are the shuffle operations required for wide dependencies, or any already computed partitions that can shortcircuit the computation of a parent RDD. The scheduler then launches tasks to compute missing partitions from each stage until it has computed the target RDD.
- 调度是被一个action触发的
- 调度器根据血统生成DAG
- 调度器将DAG划分为不同的stage,划分的原则是尽可能多的包含串行操作;
- stage的边界一般是 1)shuffle操作; 2)已经固化(保留在内存或磁盘的)RDD
- 调度器开始创建缺失数据分片的RDD,直到最后创建了目标(执行action操作的)RDD。
Our scheduler assigns tasks to machines based on data locality using delay scheduling [32]. If a task needs to process a partition that is available in memory on a node, we send it to that node. Otherwise, if a task processes a partition for which the containing RDD provides preferred locations (e.g., an HDFS file), we send it to those
以后再看。
- 如果一个task处理中需要的分片数据在另一个节点的内存中,那么将task发送到那个节点处理(而不是将数据拉过来);
- 如果一个task处理的数据分片包含本地化信息,将task发到本地化信息中认为最优的那个节点(例如HDFS就有这些信息)
For wide dependencies (i.e., shuffle dependencies), we currently materialize intermediate records on the nodes holding parent partitions to simplify fault recovery
为了简化数据恢复,当前宽依赖是将中奖结果保存到磁盘,像hdfs那样
5.2 Interpreter Integration
The
Scala interpreter normally operates by
compiling a class for each line typed by the user, loading it into the JVM, and invoking a function on it. This class includes
a singleton object that
contains the variables or functions on that line and runs the line’s code in an initialize method.For example, if the user types var x = 5 followed by println(x), the interpreter
defines a class called Line1 containing x and
causes the second line to compile to println(Line1.getInstance().x)
将每行创建一个class,每行中的变量就是class的一个成员变量;其他行引用这些变量时,是通过访问这个class的成员变量实现的。
spark做的改动:
- 使用HTTP协议让work能获取每行定义的class;
- 使用逻辑引用前面行的变量,而不是单例对象. 目的是避免JVM不把静态成员序列化的特点。
5.3 Memory Management
用户可以选择将RDD保留在内存或磁盘中;在内存中还分为原生对象和序列化对象两种形式
性能:原生对象比序列化对象快2X;比磁盘的快10X以上;
To manage the limited memory available, we use an LRU eviction policy at the level of RDDs, unless this is the same RDD as the one with the new partition
内存不足时, 使用LRU淘汰使用少的RDD,但如果一个RDD被新创建的RDD使用,则不淘汰(避免循环淘汰)
5.4 Support for Checkpointing
In general, checkpointing is useful for RDDs with long lineage graphs containing wide dependencies。
往往是为了避免RDD有过多的依赖信息。
最后的亮点:

- Apache Spark 2.2.0 中文文档 - Spark RDD(Resilient Distributed Datasets)论文 | ApacheCN
Spark RDD(Resilient Distributed Datasets)论文 概要 1: 介绍 2: Resilient Distributed Datasets(RDDs) 2.1 RDD ...
- Apache Spark RDD(Resilient Distributed Datasets)论文
Spark RDD(Resilient Distributed Datasets)论文 概要 1: 介绍 2: Resilient Distributed Datasets(RDDs) 2.1 RDD ...
- Apache Spark 2.2.0 中文文档 - Spark RDD(Resilient Distributed Datasets)
Spark RDD(Resilient Distributed Datasets)论文 概要 1: 介绍 2: Resilient Distributed Datasets(RDDs) 2.1 RDD ...
- spark hadoop 对比 Resilient Distributed Datasets
hadoop 迭代消耗大 每次迭代启动一个完整的MapReduce作业 spark 首要目标就是避免运算时 过多的网络和磁盘IO开销 Resilient Distributed Datasets ht ...
- Spark的核心RDD(Resilient Distributed Datasets弹性分布式数据集)
Spark的核心RDD (Resilient Distributed Datasets弹性分布式数据集) 原文链接:http://www.cnblogs.com/yjd_hycf_space/p/7 ...
- RDD内存迭代原理(Resilient Distributed Datasets)---弹性分布式数据集
Spark的核心RDD Resilient Distributed Datasets(弹性分布式数据集) Spark运行原理与RDD理论 Spark与MapReduce对比,MapReduce的计 ...
- Scala当中什么是RDD(Resilient Distributed Datasets)弹性分布式数据集
RDD(Resilient Distributed Datasets)弹性分布式数据集.你不好理解的话,可以把RDD就可以看成是一个简单的"动态数组"(比如ArrayList),对 ...
- 【Spark】RDD(Resilient Distributed Dataset)究竟是什么?
目录 基本概念 官方文档 概述 含义 RDD出现的原因 五大属性 以单词统计为例,一张图熟悉RDD当中的五大属性 解构图 RDD弹性 RDD特点 分区 只读 依赖 缓存 checkpoint 基本概念 ...
- Spark笔记——技术点汇总
目录 概况 手工搭建集群 引言 安装Scala 配置文件 启动与测试 应用部署 部署架构 应用程序部署 核心原理 RDD概念 RDD核心组成 RDD依赖关系 DAG图 RDD故障恢复机制 Standa ...
随机推荐
- 如何使用sftp下载Linux服务器上的文件到本地
下载Linux服务器上的文件到本地 Linux服务器上的操作 sftp xxxxx@jumper.xxxx.com 使用put命令进行文件上传,put app.log 本地操作 sftp xxxxx@ ...
- Centos7:dubbo监控中心安装,配置和使用
制作dubbo-admin.war文件 下载dubbo-admin https://github.com/alibaba/dubbo 注:2.6版本后源码中不包含dubbo-admin工程 在dubb ...
- git取消操作命令
1,移除git add . 的内容 git reset HEAD 2,移除git commit 的内容(commit_A是文件名) git rebase -i commit_A
- css折叠表格
1.html <div class="custom-fold-table"> <table cellpadding="0" cellspaci ...
- adb进阶知识,如何过滤只查看某一个app的日志
前面大概学习了adb基础,但是adb的存在,在测试人员中究竟有什么必要,以及看log时,那么多的log,让我们看个屁啊,所以这一次,我决定一定要把adb这件事情搞清楚. 1.先来看最感兴趣的adb ...
- Delphi ScrollBar组件
- Delphi CheckBox组件
- 00:Java简单了解
浅谈Java之概述 Java是SUN(Stanford University Network),斯坦福大学网络公司)1995年推出的一门高级编程语言.Java是一种面向Internet的编程语言.随着 ...
- osworkflow 入门基础
OSWorkFlow入门指南目的 这篇指导资料的目的是介绍OSWorkflow的所有概念,指导你如何使用它,并且保证你逐步理解OSWorkflow的关键内容. 本指导资料假定你已经部署OSWorkfl ...
- Dubble 01 架构模型&start project
Dubbo 01 架构模型 传统架构 All in One 测试麻烦,微小修改 全都得重新测 单体架构也称之为单体系统或者是单体应用.就是一种把系统中所有的功能.模块耦合在一个应用中的架构方式.其优点 ...