Chapter 10
Physical Memory Control Using the Resource Capping Daemon (Overview)
The resource capping daemon rcapd enables you to regulate physical memory consumption by processes running in projects that have resource caps defined. If you are running zones on your system, you can use rcapd from the global zone to regulate physical memory consumption in non-global zones. See Chapter 18, Planning and Configuring Non-Global Zones (Tasks).
The following topics are covered in this chapter.
For procedures using the rcapd feature, see Chapter 11, Administering the Resource Capping Daemon (Tasks).
Introduction to the Resource Capping Daemon
A resource cap is an upper bound placed on the consumption of a resource, such as physical memory. Per-project physical memory caps are supported.
The resource capping daemon and its associated utilities provide mechanisms for physical memory resource cap enforcement and administration.
Like the resource control, the resource cap can be defined by using attributes of project entries in the project database. However, while resource controls are synchronously enforced by the kernel, resource caps are asynchronously enforced at the user level by the resource capping daemon. With asynchronous enforcement, a small delay occurs as a result of the sampling interval used by the daemon.
For information about rcapd, see the rcapd(1M) man page. For information about projects and the project database, see Chapter 2, Projects and Tasks (Overview) and the project(4) man page. For information about resource controls, see Chapter 6, Resource Controls (Overview).
How Resource Capping Works
The daemon repeatedly samples the resource utilization of projects that have physical memory caps. The sampling interval used by the daemon is specified by the administrator. See Determining Sample Intervals for additional information. When the system's physical memory utilization exceeds the threshold for cap enforcement, and other conditions are met, the daemon takes action to reduce the resource consumption of projects with memory caps to levels at or below the caps.
The virtual memory system divides physical memory into segments known as pages. Pages are the fundamental unit of physical memory in the Solaris memory management subsystem. To read data from a file into memory, the virtual memory system reads in one page at a time, or pages in a file. To reduce resource consumption, the daemon can page out, or relocate, infrequently used pages to a swap device, which is an area outside of physical memory.
The daemon manages physical memory by regulating the size of a project workload's resident set relative to the size of its working set. The resident set is the set of pages that are resident in physical memory. The working set is the set of pages that the workload actively uses during its processing cycle. The working set changes over time, depending on the process's mode of operation and the type of data being processed. Ideally, every workload has access to enough physical memory to enable its working set to remain resident. However, the working set can also include the use of secondary disk storage to hold the memory that does not fit in physical memory.
Only one instance of rcapd can run at any given time.
Attribute to Limit Physical Memory Usage
To define a physical memory resource cap for a project, establish a resident set size (RSS) cap by adding this attribute to the project database entry:
rcap.max-rss | The total amount of physical memory, in bytes, that is available to processes in the project. |
For example, the following line in the /etc/project file sets an RSS cap of 10 gigabytes for a project named db.
db:100::db,root::rcap.max-rss=10737418240 |
Note - The system might round the specified cap value to a page size.
You can also use the projmod command to set the rcap.max-rss attribute in the /etc/project file.
For more information, see Setting the Resident Set Size Cap.
rcapd Configuration
You use the rcapadm command to configure the resource capping daemon. You can perform the following actions:
Set the threshold value for cap enforcement
Set intervals for the operations performed by rcapd
Enable or disable resource capping
Display the current status of the configured resource capping daemon
To configure the daemon, you must have superuser privileges or have the Process Management profile in your list of profiles. The System Administrator role includes the Process Management profile.
Configuration changes can be incorporated into rcapd according to the configuration interval (see rcapd Operation Intervals) or on demand by sending a SIGHUP (see the kill(1) man page).
If used without arguments, rcapadm displays the current status of the resource capping daemon if it has been configured.
The following subsections discuss cap enforcement, cap values, and rcapd operation intervals.
Using the Resource Capping Daemon on a System With Zones Installed
You can control resident set size (RSS) usage of a zone by setting the capped-memory resource when you configure the zone. For more information, see Physical Memory Control and the capped-memory Resource. You can run rcapdin a zone, including the global zone, to enforce memory caps on processes in that zone.
If you are using rcapd in a zone, you must add a project entry and configure the daemon in each zone where you want the daemon to run. rcapd will not act on processes in zones other than the one in which it is running.
When choosing memory caps for applications in different zones, you generally do not have to consider that the applications reside in different zones. The exception is per-zone services. Per-zone services consume memory. This memory consumption must be considered when determining the amount of physical memory for a system, as well as memory caps.
Note - You cannot run rcapd in an lx branded zone, but you can use the daemon from the global zone to cap memory in a branded zone.
Memory Cap Enforcement Threshold
The memory cap enforcement threshold is the percentage of physical memory utilization on the system that triggers cap enforcement. When the system exceeds this utilization, caps are enforced. The physical memory used by applications and the kernel is included in this percentage. The percentage of utilization determines the way in which memory caps are enforced.
To enforce caps, memory can be paged out from project workloads.
Memory can be paged out to reduce the size of the portion of memory that is over its cap for a given workload.
Memory can be paged out to reduce the proportion of physical memory used that is over the memory cap enforcement threshold on the system.
A workload is permitted to use physical memory up to its cap. A workload can use additional memory as long as the system's memory utilization stays below the memory cap enforcement threshold.
To set the value for cap enforcement, see How to Set the Memory Cap Enforcement Threshold.