一、是什麼構成一個可運行的topology?web
worker processes(worker進程),executors(線程)和tasks。工具
一臺Storm集羣裏面的機器可能運行一個或多個worker進程,一個worker進程運行一個特定topology的executors。ui
一個worker進程可能運行一個或多個executors。每一個executor是一個線程。一個executor運行同一個spout或者bolt的一個或多個task。線程
一個task完成具體的數據處理。code
一個worker進程執行一個topology的子集。一個worker進程屬於一個指定topology而且能夠運行屬於一個topology的一個或多個executors。一個topology由不少這樣的worker進程運行在Storm集羣的不少機器上。orm
一個task完成具體的數據處理—一個組件的任務數在整個topology的生命週期內是不變的,可是一個組件的executors數量在topology的生命週期內是能夠變的。#threads <= #tasks。默認狀況下,tasks的數量被設置成與executors的數量相等。 Storm將會在每一個executor裏面運行一個task。生命週期
二、配置一個topology的parallelism。進程
Storm裏面的"parallelism"指parallelism hint, 它表明一個組件的executor的初始數量。io
worker進程的數量:一個topology擁有的worker進程的數量。配置文件裏面設置:TOPOLOGY_WORKERS 代碼裏面設置:Config#setNumWorkersclass
executors的數量:每一個組件擁有的executors數量。 代碼裏面配置:TopologyBuilder#setSpout() TopologyBuilder#setBolt() parallelism_hint指出一個組件的初始executors的數量。
tasks的數量:每一個組件建立多少task。 配置文件裏面配置:TOPOLOGY_TASKS 代碼裏面配置:ConponentConfigurationDeclare#setNumTasks()。
另外,TOPOLOGY_MAX_TASKS_PARALLELISM限定了單個組件能夠產生的executors的最大數量。
三、改變一個topology的parallelism。
rebalanceing:這是Storm的一個漂亮的特性。worker進程的數量和executor的數量能夠動態增長或減小,而不須要重啓集羣或者重啓topology。
兩種方式:一、用Storm web UI 二、CLI工具
## 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