- 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)
来源: http://www.bubuko.com/infodetail-2806233.html