天天看點

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數

繼續閱讀