How many workers can one supervisor provide?

概述

经常被问到, 提交一个任务到nimbus, 怎么报告 “worker 不够了”, 用户就想了解supervisor的生成worker的算法.

源码

请参考 https://github.com/alibaba/jstorm/blob/master/jstorm-core/src/main/java/com/alibaba/jstorm/daemon/supervisor/Heartbeat.java

算法逻辑

 Define the amount of workers that can be run on this machine. Each worker is assigned a port to use for communication

 if supervisor.slots.ports is null, 
 the port list will be generated by cpu cores and system memory size 
 for example, 
 there are cpu_num = system_physical_cpu_num/supervisor.slots.port.cpu.weight
 there are mem_num = system_physical_memory_size/(worker.memory.size * supervisor.slots.port.mem.weight) 
 The final port number is min(cpu_num, mem_num)