来自:https://storm.apache.org/documentation/Understanding-the-parallelism-of-a-Storm-topology.html

http://blog.csdn.net/derekjiang/article/details/9040243

概念理解

原文中用了一张图来说明在一个storm cluster中,topology运行时的并发机制。

其实说白了,当一个topology在storm cluster中运行时,它的并发主要跟3个逻辑实体想过:worker,executor 和task

1. Worker 是运行在工作节点上面,被Supervisor守护进程创建的用来干活的进程。每个Worker对应于一个给定topology的全部执行任务的一个子集。反过来说,一个Worker里面不会运行属于不同的topology的执行任务。

2.

Executor可以理解成一个Worker进程中的工作线程。一个Executor中只能运行隶属于同一个component(spout/bolt)
的task。一个Worker进程中可以有一个或多个Executor线程。在默认情况下,一个Executor运行一个task。

3.

Task则是spout和bolt中具体要干的活了。一个Executor可以负责1个或多个task。每个component(spout/bolt)
的并发度就是这个component对应的task数量。同时,task也是各个节点之间进行grouping(partition)的单位。

并发度的配置

有多种方法可以进行并发度的配置,其优先级如下:

defaults.yaml < storm.yaml <
topology 私有配置 < component level(spout/bolt) 的私有配置

至于具体怎么配置,至今拷贝过来大家看看便知:

设置worker数量

设置executor数量

  • Description: 给指定component创建的executor数量
  • Configuration option: ?
  • How to set in your code (examples):

设置task数量

Here is an example code snippet to show these settings in practice:

topologyBuilder.setBolt("green-bolt", new GreenBolt(), 2)
.setNumTasks(4)
.shuffleGrouping(blue-spout);

一个运行时的topology的例子

 

The GreenBolt was configured as per the code snippet above whereas BlueSpout and YellowBolt only set the parallelism hint (number of executors). Here is the relevant code:

Config conf = new Config();
conf.setNumWorkers(2); // use two worker processes topologyBuilder.setSpout("blue-spout", new BlueSpout(), 2); // set parallelism hint to 2 topologyBuilder.setBolt("green-bolt", new GreenBolt(), 2)
.setNumTasks(4)
.shuffleGrouping("blue-spout"); topologyBuilder.setBolt("yellow-bolt", new YellowBolt(), 6)
.shuffleGrouping("green-bolt"); StormSubmitter.submitTopology(
"mytopology",
conf,
topologyBuilder.createTopology()
);

And of course Storm comes with additional configuration settings to control the parallelism of a topology, including:

  • TOPOLOGY_MAX_TASK_PARALLELISM: This setting puts a ceiling on the number of executors that can be spawned for a single component. It is typically used during testing to limit the number of threads spawned when running a topology in local mode. You can set this option via e.g. Config#setMaxTaskParallelism().

怎么样在运行过程中修改一个topology的并发度

Storm支持在不restart topology的情况下,
动态的改变(增减)worker processes的数目和executors的数目, 称为rebalancing. 

主要有两种方法可以rebalance一个topology:

  1. 使用Storm web UI 来 rebalance topology.
  2. 使用CLI 工具 rebalance topology,一个例子如下:
# Reconfigure the topology "mytopology" to use 5 worker processes,
# the spout "blue-spout" to use 3 executors and
# the bolt "yellow-bolt" to use 10 executors. storm rebalance mytopology -n 5 -e blue-spout=3 -e yellow-bolt=10

关于Storm 中Topology的并发度的理解的更多相关文章

  1. Storm基本概念以及Topology的并发度

    Spouts,流的源头 Spout是Storm里面特有的名词,Stream的源头,通常是从外部数据源读取tuples,并emit到topology Spout可以同时emit多个tupic strea ...

  2. [Storm] 并发度的理解

    Tasks & executors relation Q1. However I'm a bit confused by the concept of "task". Is ...

  3. Twitter Storm中Topology的状态

    Twitter Storm中Topology的状态 状态转换如下,Topology 的持久化状态包括: active, inactive, killed, rebalancing 四个状态. 代码上看 ...

  4. Java 中 ConcurrentHashMap 的并发度是什么?

    ConcurrentHashMap 把实际 map 划分成若干部分来实现它的可扩展性和线程安 全.这种划分是使用并发度获得的,它是 ConcurrentHashMap 类构造函数的一 个可选参数,默认 ...

  5. storm并发度理解

    1. 核心原理 一个运行中的拓扑是由什么组成的:worker进程,executors和tasks.Storm是按照下面3种主要的部分来区分Storm集群中一个实际运行的拓扑的:Worker进程.Exe ...

  6. storm源码之理解Storm中Worker、Executor、Task关系 + 并发度详解

    本文导读: 1 Worker.Executor.task详解 2 配置拓扑的并发度 3 拓扑示例 4 动态配置拓扑并发度 Worker.Executor.Task详解: Storm在集群上运行一个To ...

  7. storm基础系列之一----storm并发度概念剖析

    前言: 学了几天storm的基础,发现如果有hadoop基础,再理解起概念来,容易的多.不过,涉及到一些独有的东西,如调度,如并发度,还是很麻烦.那么,从这一篇开始,力争清晰的梳理这些知识. 在正式学 ...

  8. 用实例的方式去理解storm的并发度

    什么是storm的并发度 一个topology(拓扑)在storm集群上最总是以executor和task的形式运行在suppervisor管理的worker节点上.而worker进程都是运行在jvm ...

  9. Storm中并发程度的理解

    Storm中涉及到了很多组件,例如nimbus,supervisor等等,在参考了这两篇文章之后,对这个有了更好的理解. Understanding the parallelism of a Stor ...

随机推荐

  1. android studio每次启动都要在fetching Android sdk compoment information停好久 怎么解决?

    网上有人给出了方案:1)进入刚安装的Android Studio目录下的bin目录.找到idea.properties文件,用文本编辑器打开.2)在idea.properties文件末尾添加一行: d ...

  2. Swift - 用CATransform3DMakeRotation实现翻页效果

    Swift - 用CATransform3DMakeRotation实现翻页效果 效果 源码 https://github.com/YouXianMing/Swift-Animations // // ...

  3. 替换NSUserDefaults的方案

    替换NSUserDefaults的方案 效果 源码 https://github.com/YouXianMing/iOS-Utilities // // BaseValueStorageManager ...

  4. Dockerfile 指令汇总及解析

        原文地址:http://www.maoyupeng.com/dockerfile-command-introduction.html 什么是Dockerfile Dockerfile是由一系列 ...

  5. sys.stdout.flush()以及subprocess的用处

    sys.stdout.flush()立即把stdout缓存内容输出. subprocess与shell进行交互,执行shell命令等. 执行shell命令集合: subprocess.check_ou ...

  6. Http请求中Content-Type讲解以及在Spring MVC注解中produce和consumes配置详解

    原文地址:  https://blog.csdn.net/shinebar/article/details/54408020 引言: 在Http请求中,我们每天都在使用Content-type来指定不 ...

  7. tensorflow报错屏蔽的方法

    之前是报这样的错: OpKernel ('op: "BestSplits" device_type: "CPU"') for unknown op: BestS ...

  8. 老猪带你玩转自定义控件三——sai大神带我实现ios 8 时间滚轮控件

    ios 8 的时间滚轮控件实现了扁平化,带来很好用户体验,android没有现成控件,小弟不才,数学与算法知识不过关,顾十分苦恼,幸好在github上找到sai大神实现代码,甚为欣喜,顾把学习这个控件 ...

  9. python3 验证码去噪

    处理前图像: 处理后图像 代码 #coding:utf8 import os from PIL import Image,ImageDraw,ImageFile import numpy import ...

  10. IDEA初使用:解决搜狗输入法不跟随BUG

    IDEA初使用:解决搜狗输入法不跟随BUG https://blog.csdn.net/qq_27905183/article/details/79119237 嗯,学习了: 然而,效果不明显: