Yarn模式下动态资源调度
操作场景
对于Spark应用来说,资源是影响Spark应用执行效率的一个重要因素。当一个长期运行的服务(比如JDBCServer),若分配给它多个Executor,可是却没有任何任务分配给它,而此时有其他的应用却资源紧张,这就造成了很大的资源浪费和资源不合理的调度。
动态资源调度就是为了解决这种场景,根据当前应用任务的负载情况,实时的增减Executor个数,从而实现动态分配资源,使整个Spark系统更加健康。
操作步骤
- 需要先配置External shuffle service。
 - 登录FusionInsight Manager,选择“集群 > 服务 > Spark > 配置 > 全部配置”。在搜索框中输入“spark.dynamicAllocation.enabled”参数名称,将参数的值设置为“true”,表示开启动态资源调度功能。默认情况下关闭此功能。
 
| 
         配置项  | 
       
         说明  | 
       
         默认值  | 
      
|---|---|---|
| 
         spark.dynamicAllocation.minExecutors  | 
       
         最小Executor个数。  | 
       
         0  | 
      
| 
         spark.dynamicAllocation.initialExecutors  | 
       
         初始Executor个数。  | 
       
         0  | 
      
| 
         spark.dynamicAllocation.maxExecutors  | 
       
         最大Executor个数。  | 
       
         2048  | 
      
| 
         spark.dynamicAllocation.schedulerBacklogTimeout  | 
       
         调度第一次超时时间。  | 
       
         1s  | 
      
| 
         spark.dynamicAllocation.sustainedSchedulerBacklogTimeout  | 
       
         调度第二次及之后超时时间。  | 
       
         1s  | 
      
| 
         spark.dynamicAllocation.executorIdleTimeout  | 
       
         普通Executor空闲超时时间。  | 
       
         60s  | 
      
| 
         spark.dynamicAllocation.cachedExecutorIdleTimeout  | 
       
         含有cached blocks的Executor空闲超时时间。  | 
       
        
  | 
      
 
    使用动态资源调度功能,必须配置External Shuffle Service。