当前位置:   article > 正文

YARN调度算法配置说明_在配置yarn时,请修改调度器的配置,增加最大允许的资源分配。

在配置yarn时,请修改调度器的配置,增加最大允许的资源分配。

任务队列

YARN的任务队列的设计思路可以包括以下几个方面:

队列分级:YARN的任务队列一般会根据任务的优先级进行分级。高优先级的任务会被优先调度和执行,而低优先级的任务则可以被延后执行。这种分级可以根据任务需要的资源量、任务的重要程度等因素来确定。

资源管理:YARN的任务队列需要考虑系统中可用的资源情况,并根据任务队列中的任务需求来进行资源的分配和管理。它需要根据任务队列中任务的优先级和资源需求,合理地调度和分配资源,以确保系统的资源能够得到有效利用。

调度策略:YARN的任务队列需要设定合适的调度策略,以决定哪些任务能够获得资源并执行。调度策略可以根据任务队列中任务的优先级、资源需求和当前系统资源情况等因素来确定。常用的调度算法包括先进先出(FIFO)、公平调度(Fair Scheduler)等。

任务监控与调优:YARN的任务队列需要进行任务的监控和调优,以确保任务的运行状态和性能。它可以监控任务的进度、资源使用情况和运行状态等,根据监控数据对任务进行调优,如动态调整任务的优先级、资源分配等,以达到最优的任务执行效果。

资源使用和任务强占

在Hadoop YARN中,处理大小资源和任务强占问题的任务问题主要涉及两个方面:容器大小(Container Size)和调度算法(Scheduling Algorithm)。

容器大小处理:
容器大小是指YARN中分配给一个任务的资源量。在处理大小资源问题上,YARN可以通过设置不同的容器大小来满足不同任务对资源的需求。较大的任务可以配置较大的容器大小,以便获得更多的内存和CPU资源,而较小的任务可以配置较小的容器大小,以节约资源。

任务强占处理:
任务强占指的是当有高优先级的任务到来时,是否可以强制中断低优先级任务并将资源分配给高优先级任务。在YARN中,通过调度算法来处理任务强占问题。常用的调度算法有如下两种:

先进先出(FIFO):按照任务到达的顺序进行调度,不考虑任务的优先级。这种调度算法不会中断正在运行的低优先级任务,因此在处理大小资源和任务强占问题时可能不够灵活。

公平调度(Fair Scheduler):这是一种较为灵活的调度算法,它会根据任务的优先级和资源需求进行调度。当高优先级任务到来时,Fair Scheduler会根据任务的需求情况决定是否中断低优先级任务,并将资源分配给高优先级任务。

默认调度算法

Hadoop YARN默认的调度算法是Capacity Scheduler(容量调度器)。

Capacity Scheduler是一种基于容量的调度算法,它按照一定的资源配额来为不同的任务队列分配资源。每个队列都有一定的资源配额,当任务到达时,Capacity Scheduler会根据队列的资源配额和任务的资源需求来进行调度。

容量调度器可以配置多个队列,每个队列都有自己的资源配额。当任务到达时,调度器会将任务放入合适的队列中,并根据队列的资源配额来分配资源给任务。这种方式使得不同队列中的任务可以共享集群的资源,而不会出现某个队列占用了全部资源而影响其他队列的情况。

容量调度器还支持预留资源(如用于系统或重要任务)和抢占资源(任务优先级高的抢占任务优先级低的资源)。这样可以在集群上实现资源的公平共享和优先级调度,同时也可以保证重要任务的执行。

需要注意的是,Hadoop YARN还提供了其他调度算法,如Fair Scheduler(公平调度器),用户可以根据需要选择合适的调度算法来满足自己的需求。但是默认情况下,Hadoop YARN使用的是Capacity Scheduler作为默认的调度算法

公平调度

配置

<property>
	<name>yarn.resourcemanager.scheduler.class</name>
	<value>org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler</value>
</property> 
  • 1
  • 2
  • 3
  • 4

公平调度说明

用于指定YARN资源管理器(ResourceManager)使用的调度器类。当将配置属性yarn.resourcemanager.scheduler.class的值设置为org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler时,表示使用FairScheduler作为YARN的调度器。

FairScheduler是Hadoop YARN中的一个调度器实现,它是基于公平原则的调度算法。FairScheduler可以为不同的应用程序和任务提供公平的资源分配,确保资源在不同的应用程序和任务之间进行公平的共享和分配。

FairScheduler的工作方式和设置说明如下:

分组和队列:FairScheduler将应用程序和任务分为不同的组(pools),每个组有一个或多个队列(queues)。组和队列可以根据各种因素进行设置,如用户、部门、应用程序类型等,以实现资源的精细化管理和调度。

资源分配:FairScheduler基于公平原则来进行资源分配。它会根据队列的配置和当前资源的使用情况,确定每个队列应该分配多少资源。如果某个队列没有使用其分配的资源,那么这些资源会被重新分配给其他队列中的任务。这样可以确保资源在各个队列之间进行公平的共享和分配。

任务抢占:FairScheduler支持任务抢占,即高优先级任务可以抢占低优先级任务的资源。当高优先级任务到达时,如果资源不足,FairScheduler可以根据任务的优先级和资源需求来中断低优先级任务,并将资源分配给高优先级任务。

通过上述设置,可以使用FairScheduler作为YARN的调度器。FairScheduler可以根据不同的队列设置,实现公平的资源分配和调度,并支持任务抢占来满足不同应用程序和任务的需求。

Notice

文章的描述可能过于简略,对一些细节问题处理得不够全面,读者需要结合官方文档和实践中的经验加以理解和应用。


Task Queue

The design considerations for YARN task queues include the following aspects:

Queue Hierarchy: YARN task queues are typically structured into hierarchical levels based on task priorities. High-priority tasks are scheduled and executed first, while low-priority tasks can be delayed. The hierarchy can be determined based on factors such as the amount of resources required by tasks and the importance of tasks.

Resource Management: YARN task queues need to consider the available resources in the system and allocate them according to the requirements of the tasks in the queue. It involves scheduling and managing resources based on the priority and resource demands of the tasks in the queue, ensuring efficient utilization of system resources.

Scheduling Policies: YARN task queues require appropriate scheduling policies to determine which tasks can access and utilize resources. Scheduling policies can be determined based on factors such as task priorities, resource demands, and the current resource availability in the system. Common scheduling algorithms include First-In-First-Out (FIFO) and Fair Scheduler.

Task Monitoring and Tuning: YARN task queues need to monitor and tune tasks to ensure their execution status and performance. It involves monitoring task progress, resource utilization, and runtime status, among others. Based on monitoring data, tasks can be tuned by dynamically adjusting priorities, resource allocations, and other parameters to achieve optimal task execution.

Resource Usage and Task Preemption

In Hadoop YARN, handling resource size and task preemption issues primarily involves container size and scheduling algorithms.

Container Size Handling:
Container size refers to the amount of resources allocated to a task in YARN. To handle resource size issues, YARN can allocate different container sizes to meet the resource requirements of different tasks. Large tasks can be assigned larger container sizes to obtain more memory and CPU resources, while smaller tasks can be assigned smaller container sizes to conserve resources.

Task Preemption Handling:
Task preemption refers to the ability to interrupt lower-priority tasks and allocate resources to higher-priority tasks when they arrive. In YARN, task preemption can be addressed using scheduling algorithms. Two commonly used scheduling algorithms are:

First-In-First-Out (FIFO): Tasks are scheduled in the order of their arrival, regardless of their priorities. This scheduling algorithm does not preempt lower-priority tasks that are already running, which may be less flexible in handling resource size and task preemption issues.

Fair Scheduler: This is a more flexible scheduling algorithm that considers task priorities and resource demands. When a higher-priority task arrives, the Fair Scheduler determines whether to preempt lower-priority tasks based on their resource requirements and allocates resources to the higher-priority task.

Default Scheduling Algorithm

The default scheduling algorithm in Hadoop YARN is the Capacity Scheduler.

The Capacity Scheduler is a capacity-based scheduling algorithm that allocates resources to different task queues based on predefined resource quotas. Each queue has a specific resource quota, and when tasks arrive, the Capacity Scheduler schedules them to appropriate queues based on their requirements and the queues’ resource quotas.

The Capacity Scheduler allows the configuration of multiple queues, each with its own resource quota. When a task arrives, the scheduler puts it into the appropriate queue and assigns resources based on the queue’s resource quota. This enables resource sharing among queues without one queue monopolizing all available resources and affecting other queues.

The Capacity Scheduler also supports resource reservations (for system or important tasks) and task preemption (higher-priority tasks preempting lower-priority tasks). This ensures fair resource sharing and priority scheduling while allowing the execution of important tasks.

It is important to note that Hadoop YARN provides other scheduling algorithms, such as the Fair Scheduler, which users can choose based on their specific requirements. However, by default, Hadoop YARN uses the Capacity Scheduler as the default scheduling algorithm.

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号