Managing CPU Limits

Virtual System CPU Limits

Xen, KVM, OpenVZ and Vserver virtual systems can have limits imposed that restrict the amount of CPU they can consume on the host system. This limit is typically expressed as a percentage, where 100% means the right to use a full CPU core. On a multi-core host system, a limit could thus be set to more than 100%. It is also possible to turn off the CPU limit for a virtual system completely, which allows it to consume as much of the host's resources as it wants.

CPU limits can be used to prevent a single virtual system from overwhelming others on the same host. For example, you might want each customer to be limited to 50% CPU, meaning that 8 such systems could run on a 4-core host without impacting each other. CPU can also be over-committed, which is typically safe as most systems use CPU in bursts.

When using KVM virtualization, CPU limits can only be set when the cgroups tools are installed on the host system and the kernel supports cgroups.

Setting Limits in Cloudmin

The CPU limit for a new system can be set on the creation form, in the Resource limit options section. After creation it can be modified at Resources -> Resource Limits, and takes effect immediately without the need for a reboot.

Xen systems also support setting a CPU weighting, which determines how much CPU it is granted when the host system is over-committed. A system with a weight of 200 will get twice as much CPU as one with a weight of 100, but only if the total CPU percentages granted to running systems exceeds the host's capacity.

Virtual CPU Limits

Xen also supports multiple virtual CPU cores within a system, each of which can be mapped to a core on the host. This can be configured at Resources -> Manage Virtual CPUs. It can be useful for separating Xen systems by assigning each to a different core on the host, so that there is no possibility of contention.

KVM just supports setting the number of virtual CPUs a system has, but doesn't allow each to be pinned to a real CPU on the host. The CPU count can also be set at Resources -> Manage Virtual CPUs.

CPU Limits and System Owners

Account plans can be used to define a total CPU limit for system owners, which applies to the sum of all limits applied to systems belonging to the owner. For example, if an owner has a limit of 80% CPU he could assign 40% to one system, and 40% to another. Or he could create just a single system with a 80% limit. In no case will he be allowed to set a virtual system to unlimited CPU though.