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
 调度器的本地化策略:基于本地化的延时调度,算法论文:http://people.csail.mit.edu/matei/papers/2010/eurosys_delay_scheduling.pdf 
 以后再看。
  • 如果一个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有过多的依赖信息。

最后的亮点:





spark 笔记 2: Resilient Distributed Datasets: A Fault-Tolerant Abstraction for In-Memory Cluster Computing的更多相关文章

  1. 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 ...

  2. Apache Spark RDD(Resilient Distributed Datasets)论文

    Spark RDD(Resilient Distributed Datasets)论文 概要 1: 介绍 2: Resilient Distributed Datasets(RDDs) 2.1 RDD ...

  3. Apache Spark 2.2.0 中文文档 - Spark RDD(Resilient Distributed Datasets)

    Spark RDD(Resilient Distributed Datasets)论文 概要 1: 介绍 2: Resilient Distributed Datasets(RDDs) 2.1 RDD ...

  4. spark hadoop 对比 Resilient Distributed Datasets

    hadoop 迭代消耗大 每次迭代启动一个完整的MapReduce作业 spark 首要目标就是避免运算时 过多的网络和磁盘IO开销 Resilient Distributed Datasets ht ...

  5. Spark的核心RDD(Resilient Distributed Datasets弹性分布式数据集)

    Spark的核心RDD (Resilient Distributed Datasets弹性分布式数据集)  原文链接:http://www.cnblogs.com/yjd_hycf_space/p/7 ...

  6. RDD内存迭代原理(Resilient Distributed Datasets)---弹性分布式数据集

    Spark的核心RDD Resilient Distributed Datasets(弹性分布式数据集)   Spark运行原理与RDD理论 Spark与MapReduce对比,MapReduce的计 ...

  7. Scala当中什么是RDD(Resilient Distributed Datasets)弹性分布式数据集

    RDD(Resilient Distributed Datasets)弹性分布式数据集.你不好理解的话,可以把RDD就可以看成是一个简单的"动态数组"(比如ArrayList),对 ...

  8. 【Spark】RDD(Resilient Distributed Dataset)究竟是什么?

    目录 基本概念 官方文档 概述 含义 RDD出现的原因 五大属性 以单词统计为例,一张图熟悉RDD当中的五大属性 解构图 RDD弹性 RDD特点 分区 只读 依赖 缓存 checkpoint 基本概念 ...

  9. Spark笔记——技术点汇总

    目录 概况 手工搭建集群 引言 安装Scala 配置文件 启动与测试 应用部署 部署架构 应用程序部署 核心原理 RDD概念 RDD核心组成 RDD依赖关系 DAG图 RDD故障恢复机制 Standa ...

随机推荐

  1. LintCode 53---翻转字符串中的单词

    public class Solution { /* * @param s: A string * @return: A string */ public static String reverseW ...

  2. 帝国cms 通过tags给产品或者新闻进行分类

    1.增加TAGS分类 先找到栏目== >TAGS管理 == > 管理TAGS分类 == >增加分类 2.增加相关的tag标签,也要选好TAGS分类 3.增加自定义标签模板 具体怎么写 ...

  3. Axure(一)

    axure1.原型工具 2.软件开发 1.可行性分析2.需求分析    产品经理(和甲方对接需求,)    乙方     --   甲方 ps(专业性强,精美)  设计师        html(可变 ...

  4. TCP/IP模型层次结构

    计算机网络体系结构 (1)OSI七层协议:从上到下:应用层.表示层.会话层.传输层.网络层.数据链路层.物理层. (2)TCP/IP四层协议:从上到下:应用层,传输层.网络层.数据链路层.网络接口层. ...

  5. ArcEngine介绍

    一.ArcEngine简介ArcEngine被定位为一个嵌入式的产品,它并非面向最终用户,而是一个面向开发者的产品.对于繁冗的GIS开发工作而言,理想的解决方案是一个基于组件的实用的开发框架,且该框架 ...

  6. DedeAMPZ配置php的curl扩展

    DedeAMPZ配置php的curl扩展  curl是一个利用URL语法在命令行方式下工作的文件传输工具.它支持很多协议:FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, ...

  7. 8、linux权限-特殊权限

    特殊权限: 1.setuid setuid: 让普通用户能够临时的拥有命令的属主权限,完成一些特殊的操作. suid的授权: chmod u+s chmod u-s chmod 4755 4代表是特殊 ...

  8. kubeadm安装k8s1.13

    1.环境介绍: centos 7.4.1708 关闭selinux和iptable,环境很重要! 主机 ip地址 cpu核数 内存 swap host解析 k8s-master 10.0.0.11 2 ...

  9. 模块之time与datetime

    模块之time与datetime import time print (time.clock()) print(time.process_time()) #测量处理器运算时间 print(time.a ...

  10. PAT Basic 1020 月饼 (25 分)

    月饼是中国人在中秋佳节时吃的一种传统食品,不同地区有许多不同风味的月饼.现给定所有种类月饼的库存量.总售价.以及市场的最大需求量,请你计算可以获得的最大收益是多少. 注意:销售时允许取出一部分库存.样 ...