CPU usage in virtual machines

2

3

I have a host machine with 1 logical processor running at 2.0GHz with 2 VMs running. Each VM is running at 100 % utilization (according to Task manager inside the VM). I realize this "100%" is not accurate in the sense that actually, each VM is utilizing about 50% of available CPU resources of the host machine. Only if I stopped one of the VMs would the running VM really be using 100% of the physical CPU.

How does this process work? If the physical processor runs at 2.0GHz, are we essentially creating two virtual processors that each run at 1.0GHz? So when we see 100% utilization on both VMs, we are talking about 100% of 1.0GHz on each? How is that percent utilization derived in the first place?

Thank you!

pauliwago

Posted 2013-08-14T00:14:15.040

Reputation: 227

Answers

4

The usage that you see inside the virtual machine is the percentage of the time it wanted the CPU, whether it got it or not. Essentially, 100% means 100% of the CPU available to that virtual machine.

If the physical processor runs at 2.0GHz, then so do the virtual processors. However, because there is only one actual core, only one of the virtual processors can be running at a time. When you see 100% utilization on both VMs, you are talking about each VM always wanting as much CPU as it can get. Typically, they will each get close to 50% of the available CPU.

Don't say things like this: "So when we see 100% utilization on both VMs, we are talking about 100% of 1.0GHz on each?" That's basically nonsense. If you get to use a car that goes 50 miles per hour every other day, we don't describe that as 100% of 25 miles per hour. Rates don't work that way. The CPU has some capacity to do work, and the virtual machines share that. If each wants all they can get, then each gets around 50% of the CPU's capacity to do work. 2.0GHz is the core clock speed, not the capacity to do work. So it makes no sense to divide that.

David Schwartz

Posted 2013-08-14T00:14:15.040

Reputation: 58 310

1

On a physical CPU core there can only run one VM at a time. The vmkernel switches the cpu core between VMs very fast. To you it looks as if they run on the same CPU at the same time.

Gabrie

Posted 2013-08-14T00:14:15.040

Reputation: 141

One question: If the host and all VMs are currently fully stretched then each VM doesn't get the CPU's full computation power. Is that correct? If you have 1 core with 2 GHz und 2 VMs then effectively each single VM cannot consume 2 GHz because this CPU core is shared between both VMs. But nevertheless, each VMs "sees" that the logical CPU has a computation power of 2 GHz (which isn't fully true). Am I right? – PAX – 2019-05-21T12:47:19.633