天天看点

storm rebalance 命令调整topology并行数及问题分析1.概述 2.问题 3.问题分析与解决

原创文章,欢迎转载.转载请注明出处: http://blog.csdn.net/jmppok/article/details/17243857

1.概述

通过前面的介绍,我们知道Storm可以实现弹性计算,根据需要实时调整Topology的并行度.

参考:

1)翻译:Storm Scalable ——Storm弹性计算

2)Storm弹性计算:实时调整Topology并发数

2.问题

经过试验发现, storm rebalance  topology-name -n    调整worker数没有问题。

但在调整topology中某个spout或bolt的并行数时,有时候并不能生效。

如 storm rebalance  topology-name -e bolt1=3 命令有时候会不生效。

经过进一步分析发现,“-e bolt1=3”, 可以用于减小bolt1的并发度,但并不能增大其并发度。

也就说如果默认bolt1的并发度为5(在创建topology时设定),那么我们可以用“-e bolt1=4”将其并发度减小为4,但并不能使用“-e bolt1=6”将其并发发度调整为6。

“-e bolt1=6”命令的情况是:如果当前bolt1的并发度为5,则什么也做;如果bolt1当前的并发度小于5,将其调整为5。

3.问题分析与解决

起初以为是storm的限制,后来在网上看到的说法是:

You can only increase the parallelism (number of executors) to the number of tasks. So if your component is having for example (number of executors: 50, number of tasks: 50) then you can not increase the parallelism, however you can decrease it.

引用自:http://stackoverflow.com/questions/18716780/storm-v0-8-2-rebalance-command-not-updating-the-number-of-executors-for-a-bolt

就是说spout和bolt的并行数,最多可以调整到它的taskNum,默认情况下,taskNum是和你设置的 paralismNum相同的。

可以通过如下方法设置Bolt或Spout的taskNum。

builder.setBolt("cpp", new CppBolt(), 3)
.setNumTasks(5)
.noneGrouping(pre_name);
           

这时提交topology后,默认cpp Bolt的excutor数是3,我们可以通过rebalance -e cpp=5 将其最大调整到5。

关于topology执行时并行度,topology状态,topology执行原理等,可以参考下面这些文章:

1)Understanding the Parallelism of a Storm Topology

2) Storm 中Topology的并发度的理解 (1) 

3)Storm 中Topology的并发度的理解 (2)

4)Strom Topology执行分析:worker数,Bolt实例数,executor数,task数

继续阅读