Streaming Systems 读书笔记 (1)

Streaming Systems by Lax, Chernyak, and Akidau
Chapter 1

作者首先定义Streaming systems是处理Unbounded data,就是理论上无限数据的。作者称之为cardinality of a data set.
过去的很多流系统他认为是有缺陷的,现代的流系统应该是产出 correct, consistent, repeatable results (as any existing batch systems).

还有一个概念是constitution of a dataset. 决定了它的物理manifestation形式和如何与数据交互。

  • Table,整体数据集合,SQL使用
  • Stream,一个Element,一个Element的流

作者观点:

Lambda架构已经过时了,不再需要了。

批处理和流处理可以合二为一。Google DataFlow是这样做的。

几项必须的功能:

  1. 正确性,由快照来保证。Strong consistency。Required for exact once processing。例子:Millwheel, SparkStreaming, Flink snapshotting。
  2. 用来推理reasoning时间的工具。时间相关的分析event-time, processing-time

时间分两种:事件发生的时间event time。Processing time是数据被处理的时间。因为分布式系统的特点,两个时间之间会有一定间隔,收到的顺序也不一定和发生的顺序一致。要保证一致性,必须先定义下是哪个时间窗口的数据一致性。

问题是用哪个时间定义complete都有困难

  • processing time 的困难在于:也许因为顺序不一致,发生在前面的事件可能还在来的路上。
  • event time 的困难在于:由于分布式系统没有传输保证,你咋能确定到次(current processing time)为止,你已经收到了所有的在Event time X之前的数据。Completeness

所以就不要定Complete这个概念,随着数据收进来,数据不断更新,系统要cope with it。

Bounded data vs unbounded data

作者认为Bounded data的问题已经被Map Reduce解决了。

For unbounded data, they discussed the batch process and streaming process.

Batch process for unbounded data

  1. Fixed window. 问题没有解决
  2. session. 问题更大了,因为又多了一层需要识别的。用户的activities开始到结束是个session。但往往被分割到不同的window里面去。

Streaming process for unbounded data

几种方法:

  1. time agnostic; 时间无关,切一段就可以跑batch。运算的例子有Filtering(滤除无关信息),Inner join (Note看Inner join的定义) 收到一个record可以先等着,直到两个都收到,才把它们连接起来,输出结果。outer join就不行了,看到一个,要不要输出结果呢?另外一边的row来不来呢?需要有个timeout。
  2. approximation计算:近似算法通常对流计算比较友好。问题是要处理好Error bound,看它是不是基于event order保序的。近似计算一般是基于processing time的。作者把它归于time agnostic一类。
  3. windowing by processing time
    更普遍。固定5分钟,特别适用于观察source。比如tracking请求数量。但是如果数据逻辑是要按照event time来统计就麻烦了。系统可能会插入skew,比如cell phone在飞机上等等。
  4. windowing by event time
    2016年之前不支持event time correctness,要用Spark来保证consistency。现在的系统提供Event time consistency。但是需要更长的buffer。如何保证Completeness?答案是不保证。Flink采用Watermark来标记合理的complete。如果需要绝对的精确,那么管道就必须保证。

But for cases in which absolute correctness is paramount (again, think billing), the only real option is to provide a way for the pipeline builder to express when they want results for windows to be materialized and how those results should be refined over time.

####几种窗口:

  • Fixed window/tumbling window:对齐的固定窗口尺寸。到时候就cutoff。
  • Sliding window/Hopping window:Google翻译的还不错

固定窗口的generalization,滑动窗口由固定长度和固定周期定义。 如果周期小于长度,则窗口重叠。 如果周期等于长度,则您有固定的窗口。 如果周期大于长度,则会有一种奇怪的采样窗口,该窗口仅随时间查看数据的子集。 与固定窗口一样,滑动窗口通常是对齐的,但在某些用例中它们可以不对齐作为性能优化。

  • session窗口。就是动态窗口的例子。不是整齐划一的。窗口大小是由数据决定的
  • tuple-based windowing (i.e., windows whose sizes are counted in numbers of elements). However, tuple-based windowing is essentially a form of processing-time windowing in which elements are assigned monotonically increasing timestamps as they arrive at the system.

Note: 还有一本DDIA,好像比较浅显易懂一点。
Note: join是把两个ROW或者record(含有不同的列)来连起来,其中有一些条件。inner join是只把两个table中符合条件的连起来。outer join是把不符合条件的也包括到结果中,缺失的信息用NULL来代替。又分为Full outer join, left outer join, 和right outer join。其中left outer join就是把left table的所有行都包括进来。Right outer join就是把right table的所有行都包括进来。full outer join就是把两个table的所有ROW都包括进来。就是A left outer join B和A right outer join B的UNION。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值