Linux Control Groups (cgroups)

Cloudera Manager supports the Linux control groups (cgroups) kernel feature. With cgroups, administrators can impose per-resource restrictions and limits on services and roles. This
provides the ability to allocate resources using cgroups to enable isolation of compute frameworks from one another. Resource allocation is implemented by setting properties for the services and
roles.

Linux Distribution Support

Cgroups are a feature of the Linux kernel, and as such, support depends on the host's Linux distribution and version as shown in the following tables. If a distribution lacks support for
a given parameter, changes to the parameter have no effect.

RHEL-compatible

Distribution

CPU Shares

I/O Weight

Memory Soft Limit

Memory Hard Limit

Red Hat Enterprise Linux, CentOS, and Oracle Enterprise Linux 7

Red Hat Enterprise Linux, CentOS, and Oracle Enterprise Linux 6

Red Hat Enterprise Linux, CentOS, and Oracle Enterprise Linux 5

SLES

Distribution

CPU Shares

I/O Weight

Memory Soft Limit

Memory Hard Limit

SUSE Linux Enterprise Server 11

Ubuntu

Distribution

CPU Shares

I/O Weight

Memory Soft Limit

Memory Hard Limit

Ubuntu 14.04 LTS

Ubuntu 12.04 LTS

Ubuntu 10.04 LTS

Debian

Distribution

CPU Shares

I/O Weight

Memory Soft Limit

Memory Hard Limit

Debian 7.1

Debian 7.0

Debian 6.0

The exact level of support can be found in the Cloudera Manager Agent log file, shortly after the Agent has started. See Viewing the Cloudera Manager Server Log to find the Agent log. In the log file, look for an entry like this:

Resource Management with Control Groups

To use cgroups, you must enable cgroup-based resource management under the host resource management configuration properties. However, if you configure static service pools, this property is set as part of that process.

Enabling Resource Management

Cgroups-based resource management can be enabled for all hosts, or on a per-host basis.

If you have upgraded from a version of Cloudera Manager older than Cloudera Manager 4.5, restart every Cloudera Manager Agent before using cgroups-based resource management:

Optionally click the link of the host where you want to enable cgroups.

Click the Configuration tab.

Select Category > Resource Management.

Select Enable Cgroup-based Resource Management.

Restart all roles on the host or hosts.

Limitations

Role group and role instance override cgroup-based resource management parameters must be saved one at a time. Otherwise some of the changes that should be reflected dynamically will
be ignored.

The role group abstraction is an imperfect fit for resource management parameters, where the goal is often to take a numeric value for a host resource and distribute it amongst running
roles. The role group represents a "horizontal" slice: the same role across a set of hosts. However, the cluster is often viewed in terms of "vertical" slices, each being a combination of worker
roles (such as TaskTracker, DataNode, RegionServer, Impala Daemon, and so on). Nothing in Cloudera Manager guarantees that these disparate horizontal slices are "aligned" (meaning, that the role
assignment is identical across hosts). If they are unaligned, some of the role group values will be incorrect on unaligned hosts. For example a host whose role groups have been configured with memory
limits but that's missing a role will probably have unassigned memory.

Configuring Resource Parameters

After enabling cgroups, you can restrict and limit the resource consumption of roles (or role groups) on a per-resource basis. All of these parameters can be found in the Cloudera
Manager Admin Console, under the Resource Management category:

CPU Shares - The more CPU shares given to a role, the larger its share of the CPU when under contention. Until processes on the host (including both roles
managed by Cloudera Manager and other system processes) are contending for all of the CPUs, this will have no effect. When there is contention, those processes with higher CPU shares will be given
more CPU time. The effect is linear: a process with 4 CPU shares will be given roughly twice as much CPU time as a process with 2 CPU shares.

Updates to this parameter are dynamically reflected in the running role.

I/O Weight - The greater the I/O weight, the higher priority will be given to I/O requests made by the role when I/O is under contention (either by roles
managed by Cloudera Manager or by other system processes).

This only affects read requests; write requests remain unprioritized. The Linux I/O scheduler controls when buffered writes are flushed to disk, based on time and quantity thresholds. It
continually flushes buffered writes from multiple sources, not certain prioritized processes.

Updates to this parameter are dynamically reflected in the running role.

Memory Soft Limit - When the limit is reached, the kernel will reclaim pages charged to the process if and only if the host is facing memory pressure. If
reclaiming fails, the kernel may kill the process. Both anonymous as well as page cache pages contribute to the limit.

After updating this parameter, you must restart the role for changes to take effect.

Memory Hard Limit - When a role's resident set size (RSS) exceeds the value of this parameter, the kernel will swap out some of the role's memory. If it
is unable to do so, it will kill the process. The kernel measures memory consumption in a manner that does not necessarily match what the top or ps report for RSS, so expect that this limit is a rough approximation.

After updating this parameter, you must restart the role for changes to take effect.

Example: Protecting Production MapReduce Jobs from Impala Queries

Suppose you have MapReduce deployed in production and want to roll out Impala without affecting production MapReduce jobs. For simplicity, we will make the following assumptions:

The cluster is using homogenous hardware

Each worker host has two cores

Each worker host has 8 GB of RAM

Each worker host is running a DataNode, TaskTracker, and an Impala Daemon

Each role type is in a single role group

Cgroups-based resource management has been enabled on all hosts

Action

Procedure

CPU

Leave DataNode and TaskTracker role group CPU shares at 1024.

Set Impala Daemon role group's CPU shares to 256.

The TaskTracker role group should be configured with a Maximum Number of Simultaneous Map Tasks of 2 and a Maximum Number of Simultaneous Reduce Tasks of 1. This yields an upper bound
of three MapReduce tasks at any given time; this is an important detail for memory sizing.

If this documentation includes code, including but not limited to, code examples, Cloudera makes this available to you under the terms of the Apache License, Version 2.0, including any required
notices. A copy of the Apache License Version 2.0 can be found here.