<p>YARN supports an extensible resource model. By default YARN tracks CPU and memory for all nodes, applications, and queues, but the resource definition can be extended to include arbitrary “countable” resources. A countable resource is a resource that is consumed while a container is running, but is released afterwards. CPU and memory are both countable resources. Other examples include GPU resources and software licenses.</p>
<p>In addition, YARN also supports the use of “resource profiles”, which allow a user to specify multiple resource requests through a single profile, similar to Amazon Web Services Elastic Compute Cluster instance types. For example, “large” might mean 8 virtual cores and 16GB RAM.</p></section><section>
<h2><aname="Configuration"></a>Configuration</h2>
<p>The following configuration properties are supported. See below for details.</p>
<tdalign="left"> Comma-separated list of additional resources. May not include <code>memory</code>, <code>memory-mb</code>, or <code>vcores</code></td></tr>
<tdalign="left"> The count of the specified resource available from the node manager </td></tr>
</tbody>
</table>
<p>Please note that the <code>resource-types.xml</code> and <code>node-resources.xml</code> files also need to be placed in the same configuration directory as <code>yarn-site.xml</code> if they are used. Alternatively, the properties may be placed into the <code>yarn-site.xml</code> file instead.</p></section><section>
<p>The resource manager is the final arbiter of what resources in the cluster are tracked. The resource manager loads its resource definition from XML configuration files. For example, to define a new resource in addition to CPU and memory, the following property should be configured:</p>
<divclass="source">
<divclass="source">
<pre><configuration>
<property>
<name>yarn.resource-types</name>
<value>resource1,resource2</value>
<description>
The resources to be used for scheduling. Use resource-types.xml
to specify details about the individual resource types.
</description>
</property>
</configuration>
</pre></div></div>
<p>A valid resource name must begin with a letter and contain only letters, numbers, and any of: ‘.’, ‘_’, or ‘-’. A valid resource name may also be optionally preceded by a name space followed by a slash. A valid name space consists of period-separated groups of letters, numbers, and dashes. For example, the following are valid resource names:</p>
<ul>
<li>myresource</li>
<li>my_resource</li>
<li>My-Resource01</li>
<li>com.acme/myresource</li>
</ul>
<p>The following are examples of invalid resource names:</p>
<ul>
<li>10myresource</li>
<li>my resource</li>
<li>com/acme/myresource</li>
<li>$NS/myresource</li>
<li>-none-/myresource</li>
</ul>
<p>For each new resource type defined an optional unit property can be added to set the default unit for the resource type. Valid values are:</p>
<tableborder="0"class="bodyTable">
<thead>
<trclass="a">
<thalign="left">Unit Name </th>
<thalign="left"> Meaning </th></tr>
</thead><tbody>
<trclass="b">
<tdalign="left"> p </td>
<tdalign="left"> pico </td></tr>
<trclass="a">
<tdalign="left"> n </td>
<tdalign="left"> nano </td></tr>
<trclass="b">
<tdalign="left"> u </td>
<tdalign="left"> micro </td></tr>
<trclass="a">
<tdalign="left"> m </td>
<tdalign="left"> milli </td></tr>
<trclass="b">
<tdalign="left"></td>
<tdalign="left"> default, i.e. no unit </td></tr>
<trclass="a">
<tdalign="left"> k </td>
<tdalign="left"> kilo </td></tr>
<trclass="b">
<tdalign="left"> M </td>
<tdalign="left"> mega </td></tr>
<trclass="a">
<tdalign="left"> G </td>
<tdalign="left"> giga </td></tr>
<trclass="b">
<tdalign="left"> T </td>
<tdalign="left"> tera </td></tr>
<trclass="a">
<tdalign="left"> P </td>
<tdalign="left"> peta </td></tr>
<trclass="b">
<tdalign="left"> Ki </td>
<tdalign="left"> binary kilo, i.e. 1024 </td></tr>
<trclass="a">
<tdalign="left"> Mi </td>
<tdalign="left"> binary mega, i.e. 1024^2 </td></tr>
<trclass="b">
<tdalign="left"> Gi </td>
<tdalign="left"> binary giga, i.e. 1024^3 </td></tr>
<trclass="a">
<tdalign="left"> Ti </td>
<tdalign="left"> binary tera, i.e. 1024^4 </td></tr>
<trclass="b">
<tdalign="left"> Pi </td>
<tdalign="left"> binary peta, i.e. 1024^5 </td></tr>
</tbody>
</table>
<p>The property must be named <code>yarn.resource-types.<resource>.units</code>. Each defined resource may also have optional minimum and maximum properties. The properties must be named <code>yarn.resource-types.<resource>.minimum-allocation</code> and <code>yarn.resource-types.<resource>.maximum-allocation</code>.</p>
<p>The <code>yarn.resource-types</code> property and any unit, mimimum, or maximum properties may be defined in either the usual <code>yarn-site.xml</code> file or in a file named <code>resource-types.xml</code>. For example, the following could appear in either file:</p>
<p>Each node manager independently defines the resources that are available from that node. The resource definition is done through setting a property for each available resource. The property must be named <code>yarn.nodemanager.resource-type.<resource></code> and may be placed in the usual <code>yarn-site.xml</code> file or in a file named <code>node­resources.xml</code>. The value of the property should be the amount of that resource offered by the node. For example:</p>
<p>Note that the units used for these resources need not match the definition held by the resource manager. If the units do not match, the resource manager will automatically do a conversion.</p></section><section>
<h3><aname="Using_Resources_With_MapReduce"></a>Using Resources With MapReduce</h3>
<p>MapReduce requests three different kinds of containers from YARN: the application master container, map containers, and reduce containers. For each container type, there is a corresponding set of properties that can be used to set the resources requested.</p>
<p>The properties for setting resource requests in MapReduce are:</p>
<tdalign="left"> Sets the memory requested for the application master container to the value in MB. No longer preferred. Use <code>yarn.app.mapreduce.am.resource.memory-mb</code> instead. Defaults to 1536. </td></tr>
<tdalign="left"> Sets the memory requested for the application master container to the value in MB. No longer preferred. Use <code>yarn.app.mapreduce.am.resource.memory-mb</code> instead. Defaults to 1536. </td></tr>
<tdalign="left"> Sets the CPU requested for the application master container to the value. No longer preferred. Use <code>yarn.app.mapreduce.am.resource.vcores</code> instead. Defaults to 1. </td></tr>
<tdalign="left"> Sets the quantity requested of <code><resource></code> for the application master container to the value. If no unit is specified, the default unit for the resource is assumed. See the section on units above. </td></tr>
<tdalign="left"> Sets the memory requested for the all map task containers to the value in MB. No longer preferred. Use <code>mapreduce.map.resource.memory-mb</code> instead. Defaults to 1024. </td></tr>
<tdalign="left"> Sets the memory requested for the all map task containers to the value in MB. No longer preferred. Use <code>mapreduce.map.resource.memory-mb</code> instead. Defaults to 1024. </td></tr>
<tdalign="left"> Sets the CPU requested for the all map task containers to the value. No longer preferred. Use <code>mapreduce.map.resource.vcores</code> instead. Defaults to 1. </td></tr>
<tdalign="left"> Sets the quantity requested of <code><resource></code> for the all map task containers to the value. If no unit is specified, the default unit for the resource is assumed. See the section on units above. </td></tr>
<tdalign="left"> Sets the memory requested for the all reduce task containers to the value in MB. No longer preferred. Use <code>mapreduce.reduce.resource.memory-mb</code> instead. Defaults to 1024. </td></tr>
<tdalign="left"> Sets the memory requested for the all reduce task containers to the value in MB. No longer preferred. Use <code>mapreduce.reduce.resource.memory-mb</code> instead. Defaults to 1024. </td></tr>
<tdalign="left"> Sets the CPU requested for the all reduce task containers to the value. No longer preferred. Use <code>mapreduce.reduce.resource.vcores</code> instead. Defaults to 1. </td></tr>
<tdalign="left"> Sets the quantity requested of <code><resource></code> for the all reduce task containers to the value. If no unit is specified, the default unit for the resource is assumed. See the section on units above. </td></tr>
</tbody>
</table>
<p>Note that these resource requests may be modified by YARN to meet the configured minimum and maximum resource values or to be a multiple of the configured increment. See the <code>yarn.scheduler.maximum-allocation-mb</code>, <code>yarn.scheduler.minimum-allocation-mb</code>, <code>yarn.scheduler.increment-allocation-mb</code>, <code>yarn.scheduler.maximum-allocation-vcores</code>, <code>yarn.scheduler.minimum-allocation-vcores</code>, and <code>yarn.scheduler.increment-allocation-vcores</code> properties in the YARN scheduler configuration.</p></section></section><section>
<p>Resource profiles provides an easy way for users to request a set of resources with a single profile and a means for administrators to regulate how resources are consumed.</p>
<p>To configure resource types, the administrator must set <code>yarn.resourcemanager.resource-profiles.enabled</code> to <code>true</code> in the resource manager’s <code>yarn-site.xml</code> file. This file defines the supported profiles. For example:</p>
<divclass="source">
<divclass="source">
<pre>{
"small": {
"memory-mb" : 1024,
"vcores" : 1
},
"default" : {
"memory-mb" : 2048,
"vcores" : 2
},
"large" : {
"memory-mb": 4096,
"vcores" : 4
},
"compute" : {
"memory-mb" : 2048,
"vcores" : 2,
"gpu" : 1
}
}
</pre></div></div>
<p>In this example, users have access to four profiles with different resource settings. Note that in the <code>compute</code> profile, the administrator has configured an additional resource as described above.</p><section>
<p>The distributed shell is currently the only client that supports resource profiles. Using the distributed shell, the user can specify a resource profile name which will automatically be translated into an appropriate set of resource requests.</p>