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)