写本文原因是之前已经将官网文档阅读过几遍,但是后来工作接触spark机会较少所以没有跟进新特性,利用周末一点闲暇时间粗略阅读一篇,将自己之前遇见过的问题解决过的问题印象不深刻的问题做一下记录。

1关于RDD缓存:

Don’t spill to disk unless the functions that computed your datasets are expensive, or they filter a large amount of the data. Otherwise, recomputing a partition may be as fast as reading it from disk.  除非生成RDD的计算逻辑非常复杂,否则不要溢写到磁盘,性能低。当数据丢失重新计算都比读取磁盘快。

2 spark 加速器新特性:

While this code used the built-in support for accumulators of type Long, programmers can also create their own types by subclassing AccumulatorV2. The AccumulatorV2 abstract class has several methods which one has to override: reset for resetting the accumulator to zero, add for adding another value into the accumulator, merge for merging another same-type accumulator into this one. Other methods that must be overridden are contained in the API documentation. For example, supposing we had a MyVector class representing mathematical vectors, we could write:

支持新的方法,reset,merg等方法;reset将加速器置0,merge方法用于合并另一个类型相同的加速器。

注意:

For accumulator updates performed inside actions only, Spark guarantees that each task’s update to the accumulator will only be applied once, i.e. restarted tasks will not update the value. In transformations, users should be aware of that each task’s update may be applied more than once if tasks or job stages are re-executed.

Accumulators do not change the lazy evaluation model of Spark. If they are being updated within an operation on an RDD, their value is only updated once that RDD is computed as part of an action. Consequently, accumulator updates are not guaranteed to be executed when made within a lazy transformation like map().

核心要点是:

加速器只有在action算子执行时候才会真正运算,加速器不会改变Spark的延迟计算模型。例如错误代码:

val accum = sc.longAccumulator
data.map { x => accum.add(x); x }
// Here, accum is still 0 because no actions have caused the map operation to be computed.

  

3:Spark使用Spark提供的API进行提交作业

Launching Spark jobs from Java / Scala

The org.apache.spark.launcher package provides classes for launching Spark jobs as child processes using a simple Java API.

4:关于Structured Streaming文档新特性

Structured Streaming在Spark2.3之前是一款基于Sparl SQL引擎的流处理计算引擎,将流数据抽象为意向无界限的表,每当有流数据到来时候进行追加或者更新结果;但是当Spark2.3的到到来,Spark提供了一种新的连续更低延迟的连续流处理引擎,直白说就是不是基于微批次的而是真正的流处理引擎。

官方文档原文:

Internally, by default, Structured Streaming queries are processed using a micro-batch processing engine, which processes data streams as a series of small batch jobs thereby achieving end-to-end latencies as low as 100 milliseconds and exactly-once fault-tolerance guarantees. However, since Spark 2.3, we have introduced a new low-latency processing mode called Continuous Processing, which can achieve end-to-end latencies as low as 1 millisecond with at-least-once guarantees. Without changing the Dataset/DataFrame operations in your queries, you will be able to choose the mode based on your application requirements.

5:Structured Streaming处理流数据的过程

Spark并不保存输入的数据,处理完毕新到来的流数据之后便开始进行回收新数据,只保存新到来的流数据的状态信息(对于wordcount而言就是新来的数据的wordcount结果,然后这部分结果更新到ResultTable中)。原文:

Note that Structured Streaming does not materialize the entire table. It reads the latest available data from the streaming data source, processes it incrementally to update the result, and then discards the source data.it only keeps around the minimal intermediate state data as required to update the result 。 

延迟数据的处理:对于迟到的数据处理spark也是用watermarking机制,watermarking就是允许延迟的时间阈值,spark根据这个阈值进行清除中间状态数据。

6:关于WaterMarking原文:

a: watermarking是什么?

Since Spark 2.1, we have support for watermarking which allows the user to specify the threshold of late data, and allows the engine to accordingly clean up old state.

译文:指定的延迟阈值的数值并不是watermark,延迟时间阈值是一个单独的参数用于指定可以接受的延迟。watermark最重要的用途让计算引擎根据watermark进行清理不必要的中间状态,watermark=计算引擎看见的最大eventtime-延迟时间阈值。当迟到的数据在watermark之前的话则就放弃,否则进行处理。估计你们看着有点难懂:举个例子,例如此时watermark=12:05,突然来一个记录的时间是12:03,此时该记录将会被丢失,因为12:05之前的中间数据已经被清除,但是如果迟到的记录时间是12:06的话则就可以被正常处理。

例如图:

图中迟到的记录 (12:04 donkey)看到的watermark=12:11,12:04记录属于12:00-12:10窗口中,但是由于12:11之前的数据都被清除了,所以12:00-12:10数据被清除,所以12:04的数据是无法被处理的,因此丢丢弃。

b: watermarking如何工作?

In other words, late data within the threshold will be aggregated, but data later than the threshold will start getting dropped .

7:Continuous Processing

Continuous Processing是一个新的计算引擎,是一个真正的连续流处理引擎,高容错,低延迟等特性,但是一次性语义保证是:最少一次,即: at-least-once。

Spark2.3文档翻阅的一点简略笔记(WaterMarking)的更多相关文章

  1. css文档之盒模型阅读笔记

    前段时间抽空仔细阅读了w3c的css文档关于盒模型方面的一些基础知识.边读边记录了一些要点,在此做些整理,与大家分享,如有理解有误之处,请不吝指教. 1.综述 文档中的每个元素被描绘为矩形盒子.渲染引 ...

  2. 基于swagger进行接口文档的编写

    0. 前言 近期忙于和各个银行的代收接口联调,根据遇到的问题,对之前编写的接口进行了修改,需求收集和设计接口时想到了方方面面,生产环境下还是会遇到意想不到的问题,好在基本的执行逻辑已确定,因此只是对接 ...

  3. java简单实现用语音读txt文档

    最近比较无聊,随便翻着博客,无意中看到了有的人用VBS读文本内容,也就是读几句中文,emmm,挺有趣的,实现也很简单,都不需要安装什么环境,直接新建txt文件,输入一些简单的vbs读文本的代码,然后将 ...

  4. Elasticsearch-如何控制存储和索引文档(_source、_all、返回源文档的某些字段)

    Elasticsearch-如何控制存储和索引文档(_source._all) _source:可以在索引中存储文档._all:可以在单个字段上索引所有内容. 1. 存储原有内容的_source _s ...

  5. 下载网页中的 pdf 各种姿势,教你如何 carry 各种网页上的 pdf 文档。

    关联词: PDF 下载 FLASH 网页 HTML 报告 内嵌 浏览器 文档 FlexPaperViewer swfobject. 这个需求是最近帮一个妹子处理一下各大高校网站里的 PDF 文档下载, ...

  6. 自定义WIZ文档模板

    WIZ文档模板 1.在wiz笔记里面新建一个笔记,并将其做成一个模板 例子: 2.该作为模板的笔记制作完成后,右键-高级-另存为  导出为html格式 3.将导出的文件和文件夹(有时候只有一个htm文 ...

  7. 每天一点Linux-01文档系统

    Windows: 以多根的方式组织文档 C: D: E:Linux: 以单根的方式组织文档 / /目录结构: FSH (Filesystem Hierarchy Standard) [root@yan ...

  8. DL4NLP —— seq2seq+attention机制的应用:文档自动摘要(Automatic Text Summarization)

    两周以前读了些文档自动摘要的论文,并针对其中两篇( [2] 和 [3] )做了presentation.下面把相关内容简单整理一下. 文本自动摘要(Automatic Text Summarizati ...

  9. [转]OpenContrail 体系架构文档

    OpenContrail 体系架构文档 英文原文:http://opencontrail.org/opencontrail-architecture-documentation/ 翻译者:@KkBLu ...

随机推荐

  1. [Redis] redis在centos下安装测试

    下载软件,使用命令wget xxx,参数:url 例如: wget http://download.redis.io/releases/redis-3.0.0.tar.gz 解压缩,使用命令tar,参 ...

  2. Jquery/js引入的button的onclik事件只触发一次

    目标描述 我要实现的是:通过监听button的click事件,从而通过ajax向servlet发送请求获取数据库中的数据,然后返回的页面,并要求局部刷新 一次页面的加载是html直接页面初始化本身的 ...

  3. java数组创建

    java数组创建:int[] number = new int[10]; int[]:表明这是一个数组 new int[10]:给前面的数组类型的number变量分配10个int类型的空间大小

  4. oracle 11g 分区表创建(自动按年、月、日分区)

    前言:工作中有一张表一年会增长100多万的数据,量虽然不大,可是表字段多,所以一年下来也会达到 1G,而且只增不改,故考虑使用分区表来提高查询性能,提高维护性. oracle 11g 支持自动分区,不 ...

  5. php $_REQUEST写法防注入突破

    扫描器扫到robots.txt ,访问:http://xxx.com/robots.txt 有一个admin,但访问需要输入账号和密码. 尝试访问: http://xxx.com/index.phps ...

  6. Hadoop Mapreduce 参数 (一)

    参考 hadoop权威指南 第六章,6.4节 背景 hadoop,mapreduce就如MVC,spring一样现在已经是烂大街了,虽然用过,但是说看过源码么,没有,调过参数么?调过,调到刚好能跑起来 ...

  7. MySQL的事务的处理

    步骤: 1.开启事务 start transaction 当我们开启一个事务的时候,我们对sql的操作都发生在内存中,但是没有真正的反馈到数据库磁盘的文件中! 2.回滚 rollback 回滚,就是恢 ...

  8. bootstrap datetimepicker日期插件美化

    效果 https://segmentfault.com/img/bVbieIp?w=1029&h=461 原文链接:https://segmentfault.com/a/11900000167 ...

  9. 如何将在线电子书保存为pdf格式

    网上有很多免费的在线电子书籍,没有pdf格式,不方便离线阅读,也不方便做记录,所以找了几个将在线内容制作成pdf文件的方法. 一.如果网站上的书籍内容没有分页,所有内容都直接显示出来了,最简单,直接将 ...

  10. Java基础笔记(3) 进制与进制转换

    ---恢复内容开始--- 进制 在一般生活中,我们一直在应用的十进制,就是逢十进一,而今天我们要接触的是,计算机编程常用的进制!首先我们要知道,计算机内部运算采用的是二进制,也就是逢二进制! 1.什么 ...