(转)spark-调度策略之FAIR

【转载原因:清晰明了】

1、概述

spark有两种调度模式:FIFO、FAIR。FIFO是先进先出,有很强的顺序性,只有前一个处理完成后才会去处理后进来的。FAIR是公平调度,通过配置进行控制优先执行的任务。spark默认使用FIFO模式,如果应用场景里面有很多比较大的查询、也有很多小的查询,此时建议使用FAIR模式可以先执行小的查询在执行耗时比较旧的查询。

2、配置

默认安装spark后再conf目录下有一个fairscheduler.xml.template文件,把此文件复制一份:

#cp fairscheduler.xml.template    fairscheduler.xml

#cat fairscheduler.xml

<?xml version="1.0"?>

<!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->

<allocations>
  <pool name="default">
    <schedulingMode>FAIR</schedulingMode>
    <weight>5</weight>
    <minShare>22</minShare>
  </pool>
</allocations>

 

参数解释:

pool  name:调度池的名称

schedulingMode:调度模式,有两种FIFO、FAIR

weight:配置某个线程池的资源权重,默认为1,这里配置5,代表default池会获得5倍的资源

minShare:给每个调度池指定一个最小的shares(cpu的核数),公平调度器通过权重重新分配资源之前总是试图满足所有活动调度池的最小share,默认为0

 

修改完fairscheduler.xml文件,还需要配置spark-default.conf,添加如下内容:

#cat spark-default.conf

spark.scheduler.mode  FAIR
spark.scheduler.allocation.file /data/spark-2.2.0-bin-hadoop2.7/conf/fairscheduler.xml

 

3、使配置生效

#./stop-all.sh

#./start-all.sh

 

4、集群多任务使用

可以在fairscheduler.xml文件中添加多个调度池,配置不同的weight、minShare来控制,使用调度池要显示指定:

SET spark.sql.thriftserver.scheduler.pool=default;

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值