Anyone know of a good way to artificially generate CPU steal? I have some automation I want to test which is triggered by CPU Steal, but for the life of me I can't figure out how to force CPU Steal to occur. I've got the virtual machine pegged at 100% CPU utilization, with no stealing going on. I don't have control over the host machine, so I can't just load a bunch of VM's and get CPU Steal that way.

Anyone have any ideas? Would be greatly appreciated.

  • 3
    Install Xen and run a bunch of CPU-hogging VMs. – Michael Hampton Aug 21 '13 at 20:55
  • 3
    deploy a t1.micro on AWS. – dmourati Aug 22 '13 at 0:29
  • 1
    If your in-VM automation can be decoupled from external resources, try running a local VirtualBox/VMware/Parallels machine. Then unit test the heck out of the external dependencies. Vagrant, in particular, makes any kind of in-VM testing trivial. Once you have control over the hypervisor (whether your workstation or something else) you're golden. – Yolo Perdiem Aug 22 '13 at 1:49
  • dmourati, that actually worked rather well. Almost too well - I was able to get 80% steal by pegging the CPU of a t1.micro. Thanks. =) – Richard D Lawson Aug 22 '13 at 15:52

Without access to the host you will never be able to control this. (Or the ability to predict that your VM will share resources and contend with other VMs to the point that there are contention issues on the host.)

CPU Steal Time Definition

Steal time is the percentage of time a virtual CPU waits for a real CPU while the hypervisor is servicing another virtual processor.

You would need to add other VMs to the host that are also working near max capacity, (or relocate the VM onto a smaller host,) so that the host has a reason to let other VMs steal from your VM.

Even if the other VMs on the same host are not completely idle, if the host has plenty of excess processors with which to service whatever smaller number of vCPUs your VM has at any given moment, you can run your VM in the red 24/7 and never see any steal time.

For instance, if your VM had 4 vCPUs, and my host had 32 cores/processors, you would probably never see any steal, because giving your puny VM 4 vCPUs at any one moment is no big deal to my big beefy host.

Low resource contention = low steal time.

Edit: You might be interested in my other somewhat similar Serverfault post:

Is there a Windows equivalent of Unix 'CPU steal time'?

  • Thanks for the info, Ryan. It rather confirmed what my own testing had shown - that no matter what load I threw at a VM, if there's no resource contention on the host you'll never get CPU steal. – Richard D Lawson Aug 22 '13 at 15:55
  • Cool... I see that you were able to see steal time in your Micro instance. Clarified my answer a little bit to clarify that you don't strictly have to have control over the hypervisor per se, just that you need to be able to put yourself in a situation where you know there will be resource contention. (e.g. "noisy neighbors") – Ryan Ries Aug 22 '13 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.