How to Calculate CPU assigned to VM

This is for discussing general topics about how to use VirtualBox.
Post Reply
Ghetas
Posts: 19
Joined: 19. Dec 2015, 17:35

How to Calculate CPU assigned to VM

Post by Ghetas »

Hi everyone

i want to calculate the total amount of cpu assigned to virtual machine i know it is stupid question but i confuse about number of virtual CPU assigned to VM for example

I have Intel(R) Core(TM) i7-4770 CPU @ 3.40GHzMHz physical server and i setup virtual machine such as the following

Number of Virtual CPU: 1
Execution Cap: 50%
based on my understanding the total amount of cpu assigned to VM will be (3.40GHzMH * 8 ) / 2 = 3401MHz *8* 0.50 = 13604 MHz where the value 8 is the number of processor in physical host

Now if i make a new setup for VM for example if the number of Virtual CPU =2 and the Execution cap is 50% then the total amount of CPU assigned to VM will be the same value as before 13604 MHZ but VM will divide this value on two virtual CPU where each virtual cpu will get 13604 / 2 MHZ

please can any one clear to me is it right?

thanks
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: How to Calculate CPU assigned to VM

Post by mpack »

Moving this topic to "Using VirtualBox", since it clearly has nothing to do with "The VirtualBox API".

I'm afraid the question is rather meaningless. You don't assign a fraction of the CPU to the VM (at least not using that mechanism), you assign a number of cores. That doesn't mean that the VM will use 100% of each core, so there is simply no meaningful way to do that calculation. All you can say is that if you only assign 1 core then the max impact the VM can have (more or less) is to max out that core.

As to percentages, different OS's have different calculations. If you max out one core on a quad core then some OS's will show that as 100%, others will show it as 25%. To me the number is fairly unimportant. The important fact is that the core maxes out, which usually means a hung process.

If you are confused by cores vs threads, you shouldn't be. Cores are individual CPUs which just happen to be packaged on the same silicon, like four houses on one small plot of land. Hyperthreading is like a body with two heads: if you had two heads and each head could control your arms and legs, then in theory you could perform multiple tasks at the same time. In practice anything that involved accessing the physical world (including memory access) would soon get you in a tangle, but you'd be very good at pure thinking tasks. Hyperthreading is potentially useful, probably better than nothing, but the way it is sold (blurring the distinction between cores and threads from unwary buyers) is a scam IMHO.
Ghetas
Posts: 19
Joined: 19. Dec 2015, 17:35

Re: How to Calculate CPU assigned to VM

Post by Ghetas »

Hello mpack
i try to describe my goal in brief, i have one physical node (call it server) with 8 cores and i installed 3 virtual machines on it.
Now i want to allocate the CPU capacity of server between three virtual machines such that the max CPU that the first virtual machine VM1 can get 30% of total CPU capacity and VM2 get 40% of total CPU capacity and the last VM3 get 20% of CPU capacity
Therefore my questions is if i setup the execution cap of each VM to 30%,40% and 20 % are these values will be 30 %, 40% and 20% of total CPU capacity which equal to 8 core * 3.40GHz ?

i hope i could describe it clearly
thanks
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: How to Calculate CPU assigned to VM

Post by mpack »

Oh I see. I never use the execution cap feature, so I can't answer that question. In fact I don't even have an expectation for how it would work when multiple cores are involved.
Post Reply