- Storm介绍
- Supervisor:负责接受nimbus分配的任务,启动和停止属于自己管理的worker进程。
- Worker:运行具体处理组件逻辑的进程。
- Task:worker中每一个spout/bolt的线程称为一个task.
- Executor:在storm0.8之后,task不再与线程对应,同一个spout/bolt的task可能会共享一个线程,默认情况下,一个线程对应一个task。
- Topology:storm中运行的一个实时应用程序,因为各个组件间的消息流动形成逻辑上的一个拓扑结构。
- Spout:在一个topology中产生源数据流的组件。通常情况下spout会从外部数据源中读取数据,然后转换为topology内部的源数据。
- Bolt:在一个topology中接受数据然后执行处理的组件。Bolt可以执行过滤、函数操作、合并、写数据库等任何操作。
- Tuple:一次消息传递的基本单元,是一个value list.
- Stream:源源不断传递的tuple就组成了stream。
- Storm存在的缺陷
- Woker进程设计上的缺陷
- 很难定位一个executor线程中的某个task的性能。
- Storm的worker就是一个JVM进程,每个worker可以跑多个executor线程,目前根据Storm现有的调度机制,我们无法确定那个task被分配到了哪个worker进程上,哪台物理机器上。由于不知道task被分配到哪个worker上,有可能是同一个,考虑join的情况,一个join task和一个output 到 DB Store或其他存储的task被分配到同一个worker,这样性能可能存在问题。
- 一个executor线程会输出一个log文件,里面所有执行的task的信息都在里面,不好定位其中某个task的问题。
- 当前正在跑的topology如果重启的话,之前分派在同一个worker的task由于toplogy重启,可能不会再被分配到同一个worker进程上,这给debug带来了困难。
- 如果某个task有exception中断进程,整个worker进程被终止
- 在实际的项目中,一个execuotr线程执行多个不同的task使得垃圾回收的问题很难 track down.
- Storm默认每个worker进程的资源都是一样的。例如,一个worker需要5G,一个worker需要10G,那么我们就需配10G,这两个worker进程都是10G,浪费5G空间。
- 如果对一个worker进程进行heap dump时,可能会阻塞worker hearbeats的发送,导致supervisor认为该worker心跳超时,kill 和重启了该worker Debugging problems becomes quite challenging as a result of this behavior.
- Strom的worker进程使用线程来处理数据在task与worker进程之间的数据传输。在Strom中,每个tuple从进入storm到走出storm,在一个worker进程中需要通过四个线程的处理,这种设计很容易到达瓶颈,也很容易有Queue资源争夺的问题。 ( worker用thread和queue来做tuple的接收和发送,每个worker有一个receive-thread接收上游tuple,一个全局send-thread负责往下游发送tuple,然后executor有一个logic-thread来执行用户的代码逻辑,最后有一个本地的send-thread来做logic-thread和全局send-thread做数据通信,到这里,一个tuple需要从进入一个worker到出来总共要通过4个thread转发,效率很低。)
- Storm的Nimbus任务很多,包括调度,监听,分发JAR等等,topology非常多的时候,Nimbus将变成瓶颈。
- Nimbus不支持 worker进程细粒度的resource reservation和isolation。跑着不同Topology的worker进程在同一台Supervior上面运行,这会有抢资源相互影响的情况。Storm on YARN能够部分解决这种问题。
- Storm使用Zookeeper来管理supervisor和worker的心跳,这种方式限制了每个Topology的worker进程数,也限制了集群中topology的总数。 如果topology很多,每个topology的并发很多,这样Zookeeper就是瓶颈。
- Nimbus不是HA,Nimbus存在单点问题,一旦宕机,客户端将不能提交新的topology,也不能kill掉当前正在运行的topology。 Nimbus不是HA。
- 如果是一个已知的问题,某个bolt已经停止响应,这种机制将会无限制的 tuple drops,当处于production环境时,而我们却很难发现这些 tuple drops.
- Work done by upstream components is lost.
-
系统的行为变得不可预知.
- 一个tuple的失败会导致整个tuple tree的失败,这个topology会重新跑一次这个tuple tree。效率很低。
- topology会消耗大量的RAM来应对worker进程遇到GC超过一分钟的时刻,这会导致tuple失败的可能性
- 当一个worker进程跑多个executor线程的时候,transfer queues里面会有很多tuple。
- submittopology:提交topology到Heron集群. 此时,topology还没有进行流式处理,但是已经被激活.
- activatetopology. Topology即将开始流式处理,topology的处理架构已经创建.
- restart topology,当修改topology的配置后,需要重启topology
- deactivate topology. 当反激活topology后,topology将不会再处理流式数据,但是进程依然存在在集群中。
-
kill topology. 将topology从heron集群中彻底删除.
- 阻止多个TM的产生
- 允许其他属于该topology的进程发现该TMTopology Master管理topology,它会关注每个topology的status。
- TM(Topology Master)作为一个gateway for topology metircs through an endpoint
1. TCP Backpressure
这个策略利用TCP窗口的机制来梳理HI(Heron Instance)和其他Component的backpressure。所有的消息都是通过TCP sockets来做通信,如果某个HI处理缓慢,那么它的本地接收buffer就会被装满,在这个HI上游和数据通信的SM也会发现这个然后填满发送的buffer,这样该HI的处理速度就加快了。
2. Spout backpressure
这个Backpressure策略是和TCP Backpressure策略协同使用的,当SM发现它本地的HI运行慢时,SM就会通知本地的Spout停止读取数据,那么往该Spout发送数据的SM的buffer就会阻塞以致fill up,这是受影响的SM就会发送一条start backpressure的message到其他与之相连的SM,当其他SM收到该message时就会告诉他们本地的Spout不再读取数据,当上游缓慢的HI速度赶上来之后,SM再发一个stop backpressure的message到下游,然后停止backpressure。
HI的设计有以下两种:
(1) Single-threaded approach
主线程有一个TCP channel与本地的SM通信,等待tuple的到来,一旦tuple来了,就会调用用户的逻辑代码来执行,如果需要输出,该线程就会缓存数据,直到达到阈值,然后输出到downstream的SM。
这种设计简单,但是也有一些缺点,由于某些原因,用户的逻辑可能被block:
- Invoking the sleep system call for a finite duration of time
- Using read/write system calls for file or socket I/O
-
Calling thread synchronization primitives
(2) Two-threaded approach
- File Sink
- Graphite Sink
-
Scribe Sink
Topology Submit Sequence
Topology的生命周期描述了topology每个阶段的状态. 以下的序列图描述了当topology被提交到Heron集群后的一些列action。
当Heron CLI提交一个topology到Heron集群:
- Aurora scheduler 为这个topology分发必要的资源,安排对应的topology container(TM和container)。
- Topology Master作为第一个container出现,把信息同步到Zookeeper上,以便其他进程能够发现TM。
- Stream Manager去Zookeeper同步信息去并找到Topology Master
- Stream Manager连接Topology Master并周期性的发送心跳
- 当所有的Stream Manager都已经连接到Topology Master后,Topology Master会根据Heron的分配算法把Topology的所有任务分配到包不同的container上。这个过程叫做“physical plan”,为了确保安全,Topology Master会把“physical plan”写到Zookeeper中。
- 当“physical plan”完成后, Stream Manager会从Topology Master那里接收到完整的“physical plan”,这个”physical plan”能够帮助Stream Manager发现其他的Stream Manager。这些Stream Manager相互连接形成一个fully-connected network。
- 在此时,Heron Instance进程会发现它们本地的Stream Manager,下载“physical plan”中对应它自己的那一部分,并开始执行。
- 以上的步骤完成后,data/tuples starts flowing through the topology
-
- 失败场景处理
- ability for users to interact with their topologies
- ability for users to view metrics and trends for their topologies
- ability for users to view exceptions that occurs in the Heron Instances
- First, the provisioning of resources (e.g. for containers and even the Topology Master) is cleanly abstracted from the duties of the cluster manager, thereby allowing Heron to “play nice” with the rest of the (shared) infrastructure.
- Second, Isolation, topologies should be process based rather than thread based, since each Heron Instance is executing only a single task (e.g. running a spout or bolt), and each process should run in isolation.it is easy to debug that instance by simply using tools like jstack and heap dump with that process, to profile and to troubleshoot.
- Third, the design makes it transparent as to which component of the topology is failing or slowing down, as the metrics collection is granular, and lets us easily map an issue unambiguously to a specific process in the system.
- Fourth, by allowing component-level resource allocation, Heron allows a topology writer to specify exactly the resources for each component, thereby avoiding unnecessary over-provisioning.
- Fifth, having a Topology Master per topology allows each topology to be managed independently of each other (and other systems in the underlying cluster). In additional, failure of one topology (which can happen as user-defined code often gets run in the bolts) does not impact the other topologies.
- Sixth, In a distributed system like Heron, there are no guarantees that all system components will execute at the same speed. Heron has built-in back pressure mechanisms to ensure that topologies can self-adjust in case components lag. The backpressure mechanism allows us to achieve a consistent rate of delivering results, and a precise way to reason about the system. It is also a key mechanism that allows migrating topologies from one set of containers to another (e.g. to an upgraded set of machines).
- Finally, we now do not have any single point of failure.
- Heron is fully API and data model compatible with Apache Storm
- Markdown和扩展Markdown简洁的语法
- 代码块高亮
- 图片链接和图片上传
- LaTex数学公式
- UML序列图和流程图
- 离线写博客
- 导入导出Markdown文件
- 丰富的快捷键
快捷键
- 加粗
Ctrl + B
- 斜体
Ctrl + I
- 引用
Ctrl + Q
- 插入链接
Ctrl + L
- 插入代码
Ctrl + K
- 插入图片
Ctrl + G
- 提升标题
Ctrl + H
- 有序列表
Ctrl + O
- 无序列表
Ctrl + U
- 横线
Ctrl + R
- 撤销
Ctrl + Z
- 重做
Ctrl + Y
Markdown及扩展
Markdown 是一种轻量级标记语言,它允许人们使用易读易写的纯文本格式编写文档,然后转换成格式丰富的HTML页面。 —— [ 维基百科 ]
使用简单的符号标识不同的标题,将某些文字标记为粗体或者斜体,创建一个链接等,详细语法参考帮助?。
本编辑器支持 Markdown Extra , 扩展了很多好用的功能。具体请参考Github.
表格
Markdown Extra 表格语法:
项目 | 价格 |
---|---|
Computer | $1600 |
Phone | $12 |
Pipe | $1 |
可以使用冒号来定义对齐方式:
项目 | 价格 | 数量 |
---|---|---|
Computer | 1600 元 | 5 |
Phone | 12 元 | 12 |
Pipe | 1 元 | 234 |
定义列表
-
Markdown Extra 定义列表语法:
项目1
项目2
- 定义 A
- 定义 B 项目3
- 定义 C
-
定义 D
定义D内容
代码块
代码块语法遵循标准markdown代码,例如:
@requires_authorization
def somefunc(param1='', param2=0):
'''A docstring'''
if param1 > param2: # interesting
print 'Greater'
return (param2 - param1 + 1) or None
class SomeClass:
pass
>>> message = '''interpreter
... prompt'''
脚注
生成一个脚注1.
目录
用 [TOC]
来生成目录:
数学公式
使用MathJax渲染LaTex 数学公式,详见math.stackexchange.com.
- 行内公式,数学公式为: Γ(n)=(n−1)!∀n∈N 。
- 块级公式:
更多LaTex语法请参考 这儿.
UML 图:
可以渲染序列图:
或者流程图:
离线写博客
即使用户在没有网络的情况下,也可以通过本编辑器离线写博客(直接在曾经使用过的浏览器中输入write.blog.youkuaiyun.com/mdeditor即可。Markdown编辑器使用浏览器离线存储将内容保存在本地。
用户写博客的过程中,内容实时保存在浏览器缓存中,在用户关闭浏览器或者其它异常情况下,内容不会丢失。用户再次打开浏览器时,会显示上次用户正在编辑的没有发表的内容。
博客发表后,本地缓存将被删除。
用户可以选择 把正在写的博客保存到服务器草稿箱,即使换浏览器或者清除缓存,内容也不会丢失。
注意:虽然浏览器存储大部分时候都比较可靠,但为了您的数据安全,在联网后,请务必及时发表或者保存到服务器草稿箱。
浏览器兼容
- 目前,本编辑器对Chrome浏览器支持最为完整。建议大家使用较新版本的Chrome。
- IE9以下不支持
- IE9,10,11存在以下问题
- 不支持离线功能
- IE9不支持文件导入导出
- IE10不支持拖拽文件导入
- 这里是 脚注 的 内容. ↩