spark系統實現yarn資源的自動調度

參考:spa

http://blog.csdn.net/dandykang/article/details/48160953.net

 

    對於Spark應用來講,資源是影響Spark應用執行效率的一個重要因素。當一個長期運行 的服務(好比Thrift Server),若分配給它多個Executor,但是卻沒有任何任務分配給它,而此時有其餘的應用卻資源張,這就形成了很大的資源浪費和資源不合理的調度。 
    動態資源調度就是爲了解決這種場景,根據當前應用任務的負載狀況,實時的增減 Executor個數,從而實現動態分配資源,使整個Spark系統更加健康。
 
配置步驟:
 
    1. 須要先配置External shuffle service。參見 spark on yarn(External shuffle service)配置
    2. 在「spark-defaults.conf」中必須添加配置項「spark.dynamicAllocation.enabled」,並將該參數的值設置爲「true」,表示開啓動態資源調度功能。默認狀況下關閉此功能。
    3. 根據狀況配置一些可選參數
 
如下是基本配置參考
spark.shuffle.service.enabled                true   配置External shuffle Service服務(必定要配置啓用)
spark.shuffle.service.port                       7337
spark.dynamicAllocation.enabled         true   啓用動態資源調度
spark.dynamicAllocation.minExecutors    3    每一個應用中最少executor的個數
spark.dynamicAllocation.maxExecutors    8    每一個應用中最多executor的個數
 
 

可選參數說明:blog

 
配置項                                                                                    說明                                                                默認值
spark.dynamicAllocation.minExecutors                             最小Executor個數。                                        0 
spark.dynamicAllocation.initialExecutors                          初始Executor個數。                                        spark.dynamicAllocation.minExecutors
spark.dynamicAllocation.maxExecutors                             最大executor個數。                                        Integer.MAX_VALUE
spark.dynamicAllocation.schedulerBacklogTimeout         調度第一次超時時間。                                 1(s)
spark.dynamicAllocation.sustainedSchedulerBacklogTimeout 調度第二次及以後超時時間。      spark.dynamicAllocation.schedulerBacklogTimeout
spark.dynamicAllocation.executorIdleTimeout                  普通Executor空閒超時時間。                          60(s)
spark.dynamicAllocation.cachedExecutorIdleTimeout      含有cached blocks的Executor空閒超時時間。spark.dynamicAllocation.executorIdleTimeout的2倍
 
說明
1. 使用動態資源調度功能,必須配置External Shuffle Service。若是沒有使用External Shuffle Service,Executor被殺時會丟失shuffle文件。 
2. 配置了動態資源調度功能,就不能再單獨配置Executor的個數,不然會報錯退出。
3. 使用動態資源調度功能,能保證最少的executor的個數(spark.dynamicAllocation.minExecutors)
相關文章
相關標籤/搜索