`
m635674608
  • 浏览: 4928599 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

Storm Topology的并发度

 
阅读更多

概念

  

一个Topology可以包含一个或多个worker(并行的跑在不同的machine上), 所以worker process就是执行一个topology的子集, 并且worker只能对应于一个topology

  

一个worker可用包含一个或多个executor, 每个component (spout或bolt)至少对应于一个executor, 所以可以说executor执行一个compenent的子集, 同时一个executor只能对应于一个component

  

Task就是具体的处理逻辑对象, 一个executor线程可以执行一个或多个tasks      
但一般默认每个executor只执行一个task, 所以我们往往认为task就是执行线程, 其实不然      
task代表最大并发度, 一个component的task数是不会改变的, 但是一个componet的executer数目是会发生变化的      
当task数大于executor数时, executor数代表实际并发数      

  

worker process executes a subset of a topology.     
A worker process belongs to a specific topology and may run one or more executors for one or more components (spouts or bolts) of this topology.     
A running topology consists of many such processes running on many machines within a Storm cluster.

  

An executor is a thread that is spawned by a worker process. It may run one or more tasks for the same component (spout or bolt).

  

task performs the actual data processing — each spout or bolt that you implement in your code executes as many tasks across the cluster.     
The number of tasks for a component is always the same throughout the lifetime of a topology, but the number of executors (threads) for a component can change over time. This means that the following condition holds true: #threads ≤ #tasks.     
By default, the number of tasks is set to be the same as the number of executors, i.e. Storm will run one task per thread.

  

image 

  

 

  

Configuring the parallelism of a topology, 并发度的配置

  

The following sections give an overview of the various configuration options and how to set them in your code. There is more than one way of setting these options though, and the table lists only some of them. 

  

Storm currently has the following order of precedence for configuration settings

  

defaults.yaml < storm.yaml < topology-specific configuration < internal component-specific configuration < external component-specific configuration

  

 

  

对于并发度的配置, 在storm里面可以在多个地方进行配置, 优先级如上面所示...      
具体包含, 

  

worker processes的数目, 可以通过配置文件和代码中配置, worker就是执行进程, 所以考虑并发的效果, 数目至少应该大于machines的数目

  

executor的数目, component的并发线程数,只能在代码中配置(通过setBolt和setSpout的参数), 例如, setBolt("green-bolt", new GreenBolt(), 2

  

tasks的数目, 可以不配置, 默认和executor1:1, 也可以通过setNumTasks()配置

  

Number of worker processes

  

  • Description: How many worker processes to create for the topology across machines in the cluster. 
  • Configuration option: TOPOLOGY_WORKERS 
  • How to set in your code (examples):          

  

Number of executors (threads)

  

  • Description: How many executors to spawn per component
  • Configuration option: ? 
  • How to set in your code (examples):          

  

Number of tasks

  

  

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

  

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

In the above code we configured Storm to run the bolt GreenBolt with an initial number of two executors and four associated tasks. Storm will run two tasks per executor (thread). If you do not explicitly configure the number of tasks, Storm will run by default one task per executor.

 

Example of a running topology

The following illustration shows how a simple topology would look like in operation.   
The topology consists of three components: one spout called BlueSpout and two bolts called GreenBolt and YellowBolt.   
The components are linked such that BlueSpout sends its output to GreenBolt, which in turns sends its own output to YellowBolt.

image 

 

  
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)                   //set tasks number to 4
               .shuffleGrouping("blue-spout");

topologyBuilder.setBolt("yellow-bolt", new YellowBolt(), 6)
               .shuffleGrouping("green-bolt");

StormSubmitter.submitTopology(
        "mytopology",
        conf,
        topologyBuilder.createTopology()
    );

图和代码, 很清晰, 通过setBolt和setSpout一共定义2+2+6=10个executor threads     
并且同setNumWorkers设置2个workers, 所以storm会平均在每个worker上run 5个executors     
而对于green-bolt, 定义了4个tasks, 所以每个executor中有2个tasks

 

How to change the parallelism of a running topology, 动态的改变并发度

Storm支持在不restart topology的情况下, 动态的改变(增减)worker processes的数目和executors的数目, 称为rebalancing.     
通过Storm web UI, 或者通过storm rebalance命令, 见下面的例子

A nifty feature of Storm is that you can increase or decrease the number of worker processes and/or executors without being required to restart the cluster or the topology. The act of doing so is called rebalancing.

You have two options to rebalance a topology:

  1. Use the Storm web UI to rebalance the topology. 
  2. Use the CLI tool storm rebalance as described below. 

Here is an example of using the CLI tool:

# 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
http://www.51studyit.com/html/notes/20140329/45.html
分享到:
评论

相关推荐

    java开发的基于kafka、xlog的web日志实时分析storm topology.zip

    java开发的基于kafka、xlog的web日志实时分析storm topology.zip

    Storm流计算项目:1号店电商实时数据分析系统-33.项目3-非跳出UV-Storm topology开发二.pptx

    32.项目3-非跳出UV-Storm topology开发一 33.项目3-非跳出UV-Storm topology开发二 34.项目3-非跳出UV-Web端Servlet开发 35.项目3-非跳出UV-Web端Highcharts图表开发 36.项目3-非跳出UV-项目效果调试 37.项目3-非...

    大数据平台Storm入门到精通

    01.Storm基础知识02.Storm集群安装-1-new .avi.baiduyun.p05.Storm配置文件配置项讲解07.Storm基本API介绍08.Storm Topology的并发度09.Strom消息机制原理讲解10.Storm DRPC实战讲解

    storm提交topology的过程共1页.pdf.zip

    storm提交topology的过程共1页.pdf.zip

    STORM流计算Topology性能监控

    STORM的TOPOLOGY在线上运行时,随着数据量的增加,在一定的服务器性能及集群规模下,会渐渐达到一个极限,到达极限后,服务器的load、io、cpu、mem等可能会出现耗尽,系统很卡,storm吞吐量骤降的情况。本文档中截图...

    Storm杂谈之Topology的启动过程

    大家都知道,要提交StormTopology到Cluster,需要运行如下命令:bin目录下storm是一个Python文件,我们可以看一下Python脚本的main方法首先解析args参数,解析完了之后,把所有的参数传递给COMMANDS,由COMMANDS调用...

    Storm实战:构建大数据实时计算

    第4章和第5章阐述了Storm的并发度、可靠处理的特性;第6章~第8章详细而系统地讲解了几个高级特性:事务、DRPC和Trident;第9章以实例的方式讲解了Storm在实际业务场景中的应用;第10章总结了几个在大数据场景应用...

    IT十八掌_Storm阶段学习笔记(课堂笔记与原理图解)

    IT十八掌第三期配套资料! 1、Storm介绍及特点 2、storm的优势与应用 ...4、配置storm并发度 5、配置storm完全分布式集群 6、storm开发环境与生产环境 7、storm的topology再平衡 8、分组、自定义分组

    storm-topology-examples

    风暴拓扑示例 概述: 该项目提供了有关使用各种Apache Storm拓扑的示例集合... cd /tmp/storm-topology-examples && bash -x bin/install_mongodb.sh 如果使用HiveBolt,则创建表(您可能要修改ddl) cd /tmp/storm

    storm 示例demo

    import backtype.storm.topology.BasicOutputCollector; import backtype.storm.topology.OutputFieldsDeclarer; import backtype.storm.topology.base.BaseBasicBolt; import backtype.storm.tuple.Fields; import ...

    细细品味Storm_Storm简介及安装

    Storm分布式实时计算模式由Apache ...第9章讲解如何将Pig脚本转化为 topology,并且使用Storm-YARN部署topology,从 而将批处理系统转化为实时系统;第10章介绍如 何在云服务提供商提供的主机环境下部署和运行 Storm。

    论文研究-Storm下基于最佳并行度的贪心调度算法.pdf

    Storm默认采用轮询的调度策略,且依赖用户对topology任务的并行度配置,当配置不合理时依然会造成topology处理时延增大、吞吐量降低等问题。针对该问题,提出了一种Storm下基于最佳并行度的贪心调度算法。调度时先...

    Storm实时数据处理.[澳]Quinton Anderson(带详细书签)

    交付基于多语言实现的Storm Topology,包括Java、Clojure、Ruby和C++。 将Storm与Cassandra、Hadoop集成。 使用Cascading实现基于批处理的单词重要度算法。 创建并部署预测评分模型和分类模型。 掌握持续集成和将...

    Learning Storm

    In the first two chapters, you will learn the basics of a Storm topology and various components of a Storm cluster. In the later chapters, you will learn how to build a Storm application that can ...

    storm-kafka-xlog:java开发的基于kafka、xlog的web日志实时分析storm topology

    访问广度、sql注入和xss检测可疑度、useragent个数、是否使用代理访问),可通过设置web日志指定字段的阀值选择性的记录分析结果到mysql数据库,通过分析数据能够做很多事情,比如判断拦截恶意访问ip,了解网站访问...

    Real-time Analytics with Storm and Cassandra(PACKT,2015)

    The book starts off with the basics of Storm and its components along with setting up the environment for the execution of a Storm topology in local and distributed mode. Moving on, you will explore ...

    论文研究-Storm集群下一种基于Topology的任务调度策略.pdf

    Storm作为开源的分布式实时计算系统在业界得到了广泛应用,针对Storm自带调度策略忽略了Topology组件任务间的逻辑耦合性,从而引起大量tuple传输产生较大网络时延问题,结合进程代数将Topology等效简化为具有明显...

    Storm.Applied.Strategies.for.real-time.event.processing

    Chapter 3 Topology design Chapter 4 Creating robust topologies Chapter 5 Moving from local to remote topologies Chapter 6 Tuning in Storm Chapter 7 Resource contention Chapter 8 Storm internals

    《Storm实时数据处理》PDF.zip

    系统讲解Storm的基础知识和实时数据处理的最佳实践方法,内容涵盖Storm本地开发环境搭建、日志流数据处理、Trident、分布式远程过程调用、Topology在不同编程语言中的实现方法、Storm与Hadoop的集成方法、实时机器...

Global site tag (gtag.js) - Google Analytics