6、task,线程和executor间的关系

spark.task.cpus 2        //每个task分配的core数,默认1

--executor-cores 5        //每个执行器占用的core数.

--num-executors    2        //yarn模式指定执行器个数

solt                    //槽位,本质上对应一个线程,slot数指job最大的并发度。
                        //最发并发度是job同时启动的线程数。 = executors个数 * 每个执行器内核数 / 每个task占用内核数

测试

-- 配置方式 , 开启4个线程,
spark-shell --master yarn --deploy-mode client --executor-cores 5 --num-executors 2 --conf spark.task.cpus=2
$scala>sc.makeRDD(1 to 5 , 5).map(e=>{sendInfo(this , "map" , e+ "") ; e * 2}).collect

结果

192.168.231.102/21236/Executor task launch worker-0/$iw@1149152433/map(1)
192.168.231.102/21236/Executor task launch worker-0/$iw@1214110238/map(5)
192.168.231.102/21236/Executor task launch worker-1/$iw@1841808265/map(3)

192.168.231.103/11298/Executor task launch worker-0/$iw@1477418664/map(2)
192.168.231.103/11298/Executor task launch worker-1/$iw@573835569/map(4)

猜你喜欢

转载自www.cnblogs.com/lybpy/p/9784256.html