3.1.3.1. Using --cpulimit to Set CPU Limits

As a rule, you set a CPU limit for a virtual machine or container by using the prlctl set --cpulimit command. In the following example, the container MyCT is set to receive no more than 25% of the server CPU time even if the CPUs on the server are not fully loaded:

# prlctl set MyCT --cpulimit 25

This command sets the CPU limit for the container MyCT to 25% of the total CPU power of the server. The total CPU power of a server in per cent is calculated by multiplying the number of logical CPU cores installed on the server by 100%. So if a server has 2 logical CPU cores, 2 GHz each, the total CPU power will equal 200% and the limit for the container MyCT will be set to 500 MHz.

For example, on a hardware node with 2 logical CPU cores, 3 GHz each, the container MyCT will be able to get 25% of 6 GHz, that is, 750 MHz. To ensure that the container MyCT always has the same CPU limit on all servers, irrespective of their total CPU power, you can set the CPU limits in megahertz (MHz). For example, to make the container MyCT consume no more than 500 MHz on any hardware node, run the following command:

# prlctl set MyCT --cpulimit 500m

Note

Note: For more information on setting CPU limits for containers, see also Section 3.1.3.4, “CPU Limit Specifics”.