zoukankan      html  css  js  c++  java
  • 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;

  • 相关阅读:
    MVC 导出CSV
    用Nero 10.0 刻录系统安装盘步骤
    还原Ghost系统步骤简单描述
    在XP系统中发布MVC3项目nopCommerce2.65及配置
    Win2003合并磁盘分区
    GridView常用操作及注意点
    SPGroup 和SPUser的常用操作
    【转】密封类
    Sharepoint 常用的Cmd 命令
    SharePoint 上传文件到图片库中代码
  • 原文地址:https://www.cnblogs.com/cuishuai/p/7910348.html
Copyright © 2011-2022 走看看