Previous page

Next page

Locate page in Contents

Print this page

Managing CPU Shares and Limits

The Parallels Server Bare Metal CPU resource control utilities allow you to guarantee any virtual machine or Container the amount of CPU time this virtual machine or Container receives. The virtual machine or Container can consume more than the guaranteed value if no other virtual machines and Containers are competing for the CPU and the cpulimit parameter is not defined.

Note: The CPU time shares and limits are calculated on the basis of a one-second period. Thus, for example, if a virtual machine or Container is not allowed to receive more than 50% of the CPU time, it will be able to receive no more than half a second each second.

To get a view of the optimal share to assign to a virtual machine or Container, check the current server CPU utilization:

# vzcpucheck

Current CPU utilization: 11142

Power of the node: 125504

The output of this command displays the total number of the so-called CPU units consumed by all running virtual machines and Containers and server processes. This number is calculated by Parallels Server Bare Metal with the help of a special algorithm. The above example illustrates the situation when the server is underused. In other words, the running virtual machines and Containers can receive more CPU time than is guaranteed to them.

In the following example, the MyVM virtual machine is guaranteed to receive about 4% of the CPU time even if the server is fully used—that is, if the current CPU utilization equals the power of the server. Besides, this virtual machine will not receive more than 25% of the CPU time even if the CPU is not fully loaded:

# pctl set MyVM --cpuunits 5000 --cpulimit 25

set cpuunits 5000

set cpulimit 25%

The VM has been successfully configured.

To set the CPU time share and limit for Containers, just specify a Container ID instead of the virtual machine name and use the --save option to save the changes in the Container configuration file, for example:

# pctl set 101 --cpuunits 5000 --cpulimit 25 --save

Saved parameters for Container 101

Setting CPU limits in megahertz

In the example above, you set the CPU limit for Container 101 and the MyVM virtual machine to 25% of the whole CPU power of the Parallels server. That means that if the server CPU power is 2000 megahertz (MHz), Container 101 and the MyVM virtual machine can get up to 500 MHz each.

Now, imagine the situation when you migrate Container 101 to another server whose CPU power equals 4000 MHz. On this server, Container 101 can get 25% of 4000 MHz—that is, 1000 MHz. To deal with such situations, you can set CPU limits for virtual machines and Containers in MHz. Once you set the CPU limit in MHz, it remains the same, irrespective of the server total CPU power. For example, to make Container 101 and the MyVM virtual machine consume no more than 500 MHz on any Parallels server, you can run the following commands:

# pctl set MyVM ---cpulimit 500m

set cpulimit 500 MHz

The VM has been successfully configured.

# pctl set 101 --cpulimit 500m --save

Saved parameters for Container 101