zoukankan      html  css  js  c++  java
  • YRAN三种调度机制详解

     YRAN提供了三种调度策略

    一、FIFO-先进先出调度器

        YRAN默认情况下使用的是该调度器,即所有的应用程序都是按照提交的顺序来执行的,这些应用程序都放在一个队列中,只有在前面的一个任务执行完成之后,才可以执行后面的任务,依次执行

        缺点:如果有某个任务执行时间较长的话,后面的任务都要处于等待状态,这样的话会造成资源的使用率不高;如果是多人共享集群资源的话,缺点更是明显

    二、capacity-scheduler-容量调度器

        针对多用户的调度,容量调度器采用的方法稍有不同。集群由很多的队列组成(类似于任务池),这些队列可能是层次结构的(因此,一个队列可能是另一个队列的子队列),每个队列被分配有一定的容量。这一点于公平调度器类似,只不过在每个队列的内部,作业根据FIFO的方式(考虑优先级)调度。本质上,容量调度器允许用户或组织(使用队列自行定义)为每个用户或组织模拟出一个使用FIFO调度策略的独立MapReduce集群。相比之下,公平调度器(实际上也支持作业池内的FIFO调度,使其类似于容量调度器)强制池内公平共享,使运行的作业共享池内的资源。

        总结:容量调度器具有以下几个特点

        1、集群按照队列为单位划分资源,这些队列可能是层次结构的

        2、可以控制每个队列的最低保障资源和最高使用限制,最高使用限制是为了防止该队列占用过多的空闲资源导致其他的队列资源紧张

        3、可以针对用户设置每个用户的资源最高使用限制,防止该用户滥用资源

        4、在每个队列内部的作业调度是按照FIFO的方式调度的

        5、如果某个队列的资源使用紧张,但是另一个队列的资源比较空闲,此时可以将空闲的资源暂时借用,但是一旦被借用资源的队列有新的任务提交之后,此时被借用出去的资源将会被释放还回给原队列

        6、每一个队列都有严格的访问控制,只有那些被授权了的用户才可以查看任务的运行状态。

       配置文件的说明(capacity-scheduler.xml):

    
    <configuration>
    
      <property>
       <!--集群中允许运行和排队的最大的应用程序数量,如果如果提交的任务超过这个数量的话,那么多余的任务将不会被MR接受-->
        <name>yarn.scheduler.capacity.maximum-applications</name>
        <value>10000</value>
        <description>
          Maximum number of applications that can be pending and running.
        </description>
      </property>
    
      <!--集群中允许运行ApplicationMater的资源百分比,控制并发运行应用程序的数量-->
      <property>
        <name>yarn.scheduler.capacity.maximum-am-resource-percent</name>
        <value>0.1</value>
        <description>
          Maximum percent of resources in the cluster which can be used to run 
          application masters i.e. controls number of concurrent running
          applications.
        </description>
      </property>
    
     <!--将用于比较调度程序中的资源的ResourceCalculator实现,默认是在只使用内存的时候进行资源比较-->
      <property>
        <name>yarn.scheduler.capacity.resource-calculator</name>
        <value>org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator</value>
        <description>
          The ResourceCalculator implementation to be used to compare
          Resources in the scheduler.
          The default i.e. DefaultResourceCalculator only uses Memory while
          DominantResourceCalculator uses dominant-resource to compare
          multi-dimensional resources such as Memory, CPU etc.
        </description>
      </property>
    
     <!--指定root下的所有的队列,用逗号进行分割-->
      <property>
        <name>yarn.scheduler.capacity.root.queues</name>
        <value>default</value>
        <description>
          The queues at the this level (root is the root queue).
        </description>
      </property>
      
     <!--指定default下的所有队列,依次类推-->
      <property>
       <name>yarn.scheduler.capacity.root.user1.queues</name>
       <value>usera,userb,userc</value>
     </property>
    
      <!--指定默认default用户使用的资源百分比,因为这里root下只有default一个用户,所以使用了全部的资源-->
      <property>
        <name>yarn.scheduler.capacity.root.default.capacity</name>
        <value>100</value>
        <description>Default queue target capacity.</description>
      </property>
    
     <!--限制default下的具体的每个用户可以使用的最多的资源百分比,用小数表示,1说明是百分百-->
      <property>
        <name>yarn.scheduler.capacity.root.default.user-limit-factor</name>
        <value>1</value>
        <description>
          Default queue user limit a percentage from 0.0 to 1.0.
        </description>
      </property>
    
     <!--限制default用户最多可以得到集群总资源的百分比,这里只有一个用户,所以为百分百-->
      <property>
        <name>yarn.scheduler.capacity.root.default.maximum-capacity</name>
        <value>100</value>
        <description>
          The maximum capacity of the default queue.
        </description>
      </property>
    
     <!--队列状态:如果一个队列的状态是STOPPED,则不能向其提交应用程序或子队列提交应用程序-->
      <property>
        <name>yarn.scheduler.capacity.root.default.state</name>
        <value>RUNNING</value>
        <description>
          The state of the default queue. State can be one of RUNNING or STOPPED.
        </description>
      </property>
    
      <!--限定那些用户或者是用户组可以给给定的队列提交应用程序-->
      <property>
        <name>yarn.scheduler.capacity.root.default.acl_submit_applications</name>
       <value>*</value>
        <description>  
        The ACL of who can submit jobs to the default queue.
        </description>
      </property>
    
      <property>
        <name>yarn.scheduler.capacity.root.default.acl_administer_queue</name>
        <value>*</value>
        <description>
          The ACL of who can administer jobs on the default queue.
        </description>
      </property>
    
      <property>
        <name>yarn.scheduler.capacity.node-locality-delay</name>
        <value>40</value>
        <description>
          Number of missed scheduling opportunities after which the CapacityScheduler
          attempts to schedule rack-local containers.
          Typically this should be set to number of nodes in the cluster, By default is setting
          approximately number of nodes in one rack which is 40.
        </description>
      </property>
    
    </configuration>
    

    三、Fair-scheduler-公平调度器

        所谓的公平调度器指的是,旨在让每个用户公平的共享集群的能力。如果是只有一个作业在运行的话,就会得到集群中所有的资源。随着提交的作业越来越多,限制的任务槽会以“让每个用户公平共享集群”这种方式进行分配。某个用户的好事短的作业将在合理的时间内完成,即便另一个用户的长时间作业正在运行而且还在运行过程中。

        作业都是放在作业池中的,默认情况下,每个用户都有自己的作业池。提交作业数较多的用户,不会因此而获得更多的集群资源。可以用map和reduce的任务槽数来定制作业池的最小容量,也可以设置每个池的权重。

        公平调度器支持抢占机制。所以,如果一个池在特定的一段时间内未能公平的共享资源,就会终止运行池中得到过多的资源的任务,把空出来的任务槽让给运行资源不足的作业池。

        主要特点:

          1、也是将集群的资源以队列为单位进行划分,称为队列池

          2、每个用户都有自己的队列池,如果该队列池中只有一个任务的话,则该任务会使用该池中的所有资源

          3、每个用户提交作业都是提交到自己的队列池中,所以,提交作业数较多的用户,并不会因此而获得更多的集群资源

          4、支持抢占机制。也就是说如果一个吃在特定的时间内未能公平的共享资源,就会终止池中占用过多资源的任务,将空出来的任务槽让给运行资源不足的作业池。

          5、负载均衡:提供一个基于任务数目的负载均衡机制。该机制尽可能的将任务均匀的分配到集群的所有的节点上。

    示例说明:

    Spark On Yarn  VCore Userd 值不正常,目前集群有两个任务再跑,每个任务使用1cores。

    spark-submit --master yarn --num-executors 9 --executor-memory 5g --executor-cores 10  --class org.apache.spark.examples.SparkPi spark-examples_2.11-2.3.2.3.1.0.0-78.jar 

    在执行下面的脚本的时候。资源使用如下图:

    --executor-cores 10 并不生效 

    yarn默认情况下,只根据内存调度资源,所以spark on yarn运行的时候,即使通过--executor-cores指定vcore个数为N,但是在yarn的资源管理页面上看到使用的vcore个数还是1. 相关配置在capacity-scheduler.xml 文件:

    <property>
        <name>yarn.scheduler.capacity.resource-calculator</name>
        <value>org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator</value>
        <description>
          The ResourceCalculator implementation to be used to compare
          Resources in the scheduler.
          The default i.e. DefaultResourceCalculator only uses Memory while
          DominantResourceCalculator uses dominant-resource to compare
          multi-dimensional resources such as Memory, CPU etc.
        </description>
      </property>
    

    我们应该考虑使用DominantResourceCalculator,该资源计算器在计算资源的时候会综合考虑cpu和内存的情况,来决定yarn最后的调度。

    
    <property>
      <name>yarn.scheduler.capacity.resource-calculator</name>
      <!-- <value>org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator</value> -->
      <value>org.apache.hadoop.yarn.util.resource.DominantResourceCalculator</value>
    </property>

    官方文档:http://hadoop.apache.org/docs/r2.7.3/hadoop-yarn/hadoop-yarn-site/CapacityScheduler.html


     
     

  • 相关阅读:
    evernote100个做笔记的好方法
    平衡二叉树的调整模版
    晨间日记的奇迹
    hdu 2952 Counting Sheep
    hdu 1535 Invitation Cards
    poj 3259 Wormholes(spfa)
    poj 2263 Heavy Cargo(floyd)
    poj 3268 Silver Cow Party(SPFA)
    hdu 1690 Bus System
    hdu 3631 Shortest Path(Floyd)
  • 原文地址:https://www.cnblogs.com/candlia/p/11919899.html
Copyright © 2011-2022 走看看