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;

  • 相关阅读:
    Finer Resolution Observation and Monitoring -Global Land Cover更精细的分辨率观测和监测-全球土地覆盖
    MapServer教程3
    手写Tomcat源码
    室内无线局域网
    基于点云的3ds Max快速精细三维建模方法及系统的制作方法 插件开发
    Web Mapping Illustrated Using Open Source GIS Toolkits
    apache Internal Server Error 解决方法
    php命令行工具
    小程序:将gbk转为utf-8
    java FileUtil(文件操作类)
  • 原文地址:https://www.cnblogs.com/cuishuai/p/7910348.html
Copyright © 2011-2022 走看看