OpenVZ: limit number of cpu cores per VE

Solution 1:

If you vz is number 101, than use the following to set it two 2 CPUs (change the number accordingly):

vzctl set 101 --cpus 2 --save

No restart of the VE required. The --save makes it so when the VE is rebooted, the changes will still be there. vzctl --help for other resources that can be set.

Solution 2:

OpenVZ isn't really virtualization. It's containerization. So each container sees the system that it's on as it's own. To control how much cpu time each VE can get you have to assign each VE cpucredits. This page goes into how set the limits on each VE.

Edit: Just found this in the vzctl man page.
--cpulimit num[%] Limit of CPU usage for the VE, in per cent. Note if the computer has 2 CPUs, it has total of 200% CPU time. Default CPU limit is 0 (no CPU limit). --cpus num sets number of CPUs available in the VE.

So Kyle's answer is correct. But I'll leave this answer here b/c there are more than one nob here to tweak.