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;

spark-调度策略之FAIR的更多相关文章

  1. Spark 资源调度及任务调度

    1.  资源分配 通过SparkSubmit进行提交应用后,首先会创建Client将应用程序(字节码文件.class)包装成Driver,并将其注册到Master.Master收到Client的注册请 ...

  2. Spark Scheduler内部原理剖析

    文章正文 通过文章“Spark 核心概念RDD”我们知道,Spark的核心是根据RDD来实现的,Spark Scheduler则为Spark核心实现的重要一环,其作用就是任务调度.Spark的任务调度 ...

  3. spark总结——转载

    转载自:    spark总结 第一个Spark程序 /** * 功能:用spark实现的单词计数程序 * 环境:spark 1.6.1, scala 2.10.4 */ // 导入相关类库impor ...

  4. Spark资源调度及任务调度

    1.  资源分配 通过SparkSubmit进行提交应用后,首先会创建Client将应用程序(字节码文件.class)包装成Driver,并将其注册到Master.Master收到Client的注册请 ...

  5. spark HA 安装配置和使用(spark1.2-cdh5.3)

    安装环境如下: 操作系统:CentOs 6.6 Hadoop 版本:CDH-5.3.0 Spark 版本:1.2 集群5个节点 node01~05 node01~03 为worker. node04. ...

  6. 【Spark学习】Apache Spark作业调度机制

    Spark版本:1.1.1 本文系从官方文档翻译而来,转载请尊重译者的工作,注明以下链接: http://www.cnblogs.com/zhangningbo/p/4135905.html 目录 概 ...

  7. Spark 异步Action

    异步不保序,但大作业执行时间后移. .set("spark.scheduler.mode", "FAIR") 公平调度,充分使用集群资源. Spark Doc ...

  8. 【原创】大数据基础之Spark(4)RDD原理及代码解析

    一 简介 spark核心是RDD,官方文档地址:https://spark.apache.org/docs/latest/rdd-programming-guide.html#resilient-di ...

  9. spark集群构建

    一.spark启动有standalong.yarn.cluster,具体的他们之间的区别这里不在赘述,请参考官网.本文采用的是standalong模式进行搭建及将接使用. 1.首先去官网下载需要的sp ...

随机推荐

  1. pycharm的注册码,所有版本

    77751S0VBA-eyJsaWNlbnNlSWQiOiI3Nzc1MVMwVkJBIiwibGljZW5zZWVOYW1lIjoi5b285bK4IHNvZnR3YXJlMiIsImFzc2lnb ...

  2. hive 动态分区与混合分区

    hive的分区概念,相信大家都非常了解了.通过将数据放在hdfs不同的文件目录下,查表时,只扫描对应分区下的数据,避免了全表扫描. 提升了查询效率. 关于hive分区,我们还会用到多级分区.动态分区. ...

  3. hive的 order by & distribute by & cluter by

    我们应该都清楚order by 的含义: 根据某个字段对输出的数据排序,因为只有一个reducer,所以查询效率较慢. 那么hive中,另外两个排序,distribute by和cluster by的 ...

  4. CSS 基础 例子 display属性:block、inline和inline-block的区别

    HTML中块级元素(block)和行级元素(inline):比如div就是常见的块级元素,span就是常见的行级元素. 可以通过css的display属性来设置一个元素到底是块级,还是行级元素:dis ...

  5. map 小模板~~~ 写的不好 继续添加

    #include<map>#include<string.h>#include<iostream>using namespace std; int main(){  ...

  6. Lerning Entity Framework 6 ------ Defining Relationships

    There are three types of relationships in database. They are: One-to-Many One-to-One Many-to-Many Th ...

  7. linux 的计划任务 定时任务

    linux的计划任务,也叫做定时任务 https://www.cnblogs.com/mingforyou/p/3930636.html 名字是crond 查看linux本机的定时任务 crontab ...

  8. [Vuejs] webpack+vue-cli打包如何引用相对路径

    默认情况下通过webpack+vuec-li打包的css.js等资源,路径都是绝对的,即static在根目录下,假如部署到带有文件夹目录的项目中,资源路径就会出错,如何解决. 1.修改资源引用相对路径 ...

  9. 【hyperscan】编译hyperscan 4.0.0

    ref: http://01org.github.io/hyperscan/dev-reference/getting_started.html 1. 硬件需求 intel x86处理器 64-bit ...

  10. Redis---SDS(简单动态字符串)

    Redis 没有直接使用 C 语言传统的字符串表示(以空字符结尾的字符数组,以下简称 C 字符串), 而是自己构建了一种名为简单动态字符串(simple dynamic string,SDS)的抽象类 ...