Configuring CGroups in YARN
CGroups is a mechanism for aggregating/partitioning sets of tasks, and all their future children, into hierarchical groups with specialized behavior. CGroups is a Linux kernel feature and was merged into kernel version 2.6.24. From a YARN perspective, this allows containers to be limited in their resource usage. A good example of this is CPU usage. Without CGroups, it becomes hard to limit container CPU usage. Currently, CGroups is used only for limiting CPU usage.
Before you begin
Procedure
To enable CGroups:
Results
You are now able to use CGroups to limit CPU usage. The following settings are related to
limiting resource usage of YARN containers. You may adjust these according to the resource
requirements on your system:
- Update this setting to adjust the CPU usage of all YARN containers:
yarn.nodemanager.resource.percentage-physical-cpu-limit
-
Update this setting to determine how spare CPU is used:
When set to true, containers cannot use more CPU than allocated, even when it is available. When set to false, containers can use spare CPU when it is available.yarn.nodemanager.linux-container-executor.cgroups.strict-resource-usage
Note: If running in non-secure mode, by default the LinuxContainerExecutor runs all jobs as user
nobody. When running a job the exception below may
occur:
Requested user nobody is not whitelisted and has id 99,which is below the minimum allowed 200
To
resolve this, do any of the following options as required:- Add the yarn.nodemanager.linux-container-executor.nonsecure-mode.local-user property and set it to the desired user.
- Configure the LinuxContainerExecutor to run jobs as the user submitting the job by adding property yarn.nodemanager.linux-container-executor.nonsecure-mode.limit-users and setting it to false.
- set min.user.id to a lower value in /etc/hadoop/conf/container-executor.cfg in all NodeManagers.
What to do next
For more information about YARN CGroups see http://hadoop.apache.org/docs/current/hadoop-yarn/hadoop-yarn-site/NodeManagerCgroups.html.