在數(shù)據(jù)高峰期會(huì)出現(xiàn)大量job處于queened狀態(tài),可以通過調(diào)高num-executors參數(shù),以及調(diào)高程序的并法度,來解決這個(gè)問題,但大多數(shù)情況下,根本用不了這么多資源,所以啟用資源的動(dòng)態(tài)管理解決這個(gè)問題
方法:
配置參數(shù)
1. 不開啟動(dòng)態(tài)調(diào)度. --num-executors=XXX
2. 開啟動(dòng)態(tài)調(diào)度:
--conf spark.dynamicAllocation.initialExecutors=10 (剛開始分配的Executor個(gè)數(shù), 可默認(rèn), 默認(rèn)0)
--conf spark.dynamicAllocation.minExecutors=2 (最小的Executor個(gè)數(shù), 可默認(rèn), 默認(rèn)0)
--conf spark.dynamicAllocation.maxExecutors=10 (最多的Executor個(gè)數(shù))
--conf spark.dynamicAllocation.enabled=true
如果出現(xiàn)任務(wù)等待,會(huì)動(dòng)態(tài)添加executor個(gè)數(shù),加快數(shù)據(jù)處理速度,當(dāng)數(shù)據(jù)量減少,默認(rèn)在1min沒有新的task執(zhí)行的時(shí)候,就會(huì)讓出之前的executor