How to allocate CPU resources for a VM correctly?

emptness

Member
Aug 19, 2022
112
6
23
Hello!
Can someone tell me how to properly allocate CPU resources for a VM?
I realized that the Sockets and Core values for the VM must match the characteristics of the physical host (the hypervisor itself).
And the VCPUs parameter sets the amount of resources actually provided for the VM. If I set it up this way, will it be correct?
Maybe someone can give a link where it is described in detail?

1692271412882.png
 
i never thought of it that way. i thought you assign sockets and cores according to what you need the VM to see (for things like software licensing.) i just set the socket to 1, and then add as many cores as i want the vm to have. i always thought the vCPU's were how many hyperthreads you want it to have. i could be wrong, and you are right. i don't know.
 
i never thought of it that way. i thought you assign sockets and cores according to what you need the VM to see (for things like software licensing.) i just set the socket to 1, and then add as many cores as i want the vm to have. i always thought the vCPU's were how many hyperthreads you want it to have. i could be wrong, and you are right. i don't know.
I have my doubts too.
For example, the documentation says that when the NAME option is enabled, it is better to set Sockets and Cores equal to physical ones on the hypervisor.
And the most interesting thing is that the hot expansion of processor power can occur only with the VCPUs parameter, but within Sockets*Cores.

https://pve.proxmox.com/pve-docs/chapter-qm.html
 
  • Like
Reactions: jsterr
I have my doubts too.
For example, the documentation says that when the NAME option is enabled, it is better to set Sockets and Cores equal to physical ones on the hypervisor.
And the most interesting thing is that the hot expansion of processor power can occur only with the VCPUs parameter, but within Sockets*Cores.

https://pve.proxmox.com/pve-docs/chapter-qm.html
I would like to receive confirmation from Proxmox specialists.
Did I read the documentation correctly? )))
Do I need to set the Sockets and Cores parameters equal to the physical ones on the hypervisor?
 
Do I need to set the Sockets and Cores parameters equal to the physical ones on the hypervisor?
No!

For a VM to run the configured Cores needs to be available at the same time, so the upper limit is theoretically the number of physical cores. (And sockets if NUMA is involved.)

But do not do this. The host itself needs some resources too - possibly also at the same time.

(( The sum of virtual cores assigned to several VMs may be much higher though. CPU over-commitment when running tens or hundreds of VMs is one of the main features of virtualization ;-) ))

And please note that "HyperThreading" is not really a core. So personally I would never assign a number of cores higher than real cores (w/o HT) minus two.

YMMV
 
No!

For a VM to run the configured Cores needs to be available at the same time, so the upper limit is theoretically the number of physical cores. (And sockets if NUMA is involved.)

But do not do this. The host itself needs some resources too - possibly also at the same time.

(( The sum of virtual cores assigned to several VMs may be much higher though. CPU over-commitment when running tens or hundreds of VMs is one of the main features of virtualization ;-) ))

And please note that "HyperThreading" is not really a core. So personally I would never assign a number of cores higher than real cores (w/o HT) minus two.

YMMV
Then it is better to set the VMs value to half of the physical cores of the hypervisor, for example.
So that we can use a hot CPU extension.
Well, and make sure that the amount of vCPUs on all VMs does not exceed the number of physical cores by much?
 
Well, and make sure that the amount of vCPUs on all VMs does not exceed the number of physical cores by much?
That really depends on actual usage.

In my world most of my ~80 VMs (in a cluster, not on a single node) are running idle. Always (well, nearly). I have no problem to overcommit CPU count massively. Of course you need to watch the CPU usage in your own use case! (And disk load and network traffic and ... and ...)

In my small world the limiting resource is usually RAM - and that is not a good idea to overcommit as the side effects may be... surprising. (Out-of-memory killer will stop VMs brutally and balloning does not always work as one wishes.)

Best regards
 
Last edited:
  • Like
Reactions: emptness
In my world most of my ~80 VMs (in a cluster, not on a single node) are running idle. Always (well, nearly). I have no problem to overcommit CPU count massively. Of course you need to watch the CPU usage in your own use case! (And disk load and network traffic and ... and ...)

In my small world the limiting resource is usually RAM - and that is not a good idea to overcommit as the side effects may be... surprising. (Out-of-memory killer will stop VMs brutally and balloning does not always work as one wishes.)
Our worlds are very similar, only my numbers are much bigger ;)
 
I have Intel Xeon(R) Gold 5320 installed with 26 cores (52 threads) x2 sockets.
Proxmox shows 104 CPUs.
Tell me how it would be more correct to configure the processor for the VM.
For example, sockets = 2, cores = 20 (6 less to leave resources to the hypervisor) and vCPUs = 10.
Would that be correct in your opinion?

1699011438737.png
 
For me 2*20 gives 40 ;-)

But yes, this fits my personal understanding.
I don't need more than 10 vCPUs.
And sockets and cores are for the possibility of expansion in the future.
Or do I understand something wrong?)))
 
I don't need more than 10 vCPUs.

Actually this thread seems to be by far too long for this topic. Or I simply do not understand your problem :-)

In any case: if you need only 10 vCPUs in one (or several!) VM then configure one socket with 10 cores!

This is definitely true as long as one physical CPU has more than 10 cores - which is the case for your Xeons :-)


Best regards
 
Actually this thread seems to be by far too long for this topic. Or I simply do not understand your problem :)

In any case: if you need only 10 vCPUs in one (or several!) VM then configure one socket with 10 cores!

This is definitely true as long as one physical CPU has more than 10 cores - which is the case for your Xeons :)


Best regards
With this setup, there will be no possibility of hot expansion of processors on the VM.
This is the essence of my question. How to properly configure the parameters of the CPU VM so that there are no problems and, if necessary, it is possible to increase the number of processors without restarting.

By the way, I noticed that with an increase in the number of vCPUs in the proxmox web interface, everything works, but the pre-installed cores are not displayed in the guest OS.
 
How to properly configure the parameters of the CPU VM so that there are no problems and, if necessary, it is possible to increase the number of processors without restarting.
As long as cpu and memory hotplugging (this is much more important) is enabled in Options -> Hotplug and you have proper OS support for that, you can start to play around with it.

Generally, why do you think you need to hotplug something? Normally, you need to reboot your machine due to some critical os update and a restart anyway.
 
And can someone else tell me what the "CPU Limit" parameter is and how to configure it correctly?
For example, I want to assign VM 4 CPUs. I have set the settings in the picture.
The number of sockets and cores was set up specifically more so that vCPUs could be increased without rebooting, if necessary in the future. In order for the guest OS to see only 4 vCPUs, I set vCPUs =4. But I don't want the VM to use more than 4 cores and therefore set CPU limit=4.
Am I doing the right thing?
In the documentation, this moment is poorly described for me.
What are we limiting with the CPU limit parameter? That the VM will not use more than 4 cores of physical CPUs?
 
As long as cpu and memory hotplugging (this is much more important) is enabled in Options -> Hotplug and you have proper OS support for that, you can start to play around with it.

Generally, why do you think you need to hotplug something? Normally, you need to reboot your machine due to some critical os update and a restart anyway.
And if I don't want to reboot the production, but I need to give it more resources? For example, the service slows down because users are actively working in it and it lacks dedicated vCPUs. For the same purpose, the Hotplug functionality was invented.
 
And if I don't want to reboot the production, but I need to give it more resources? For example, the service slows down because users are actively working in it and it lacks dedicated vCPUs. For the same purpose, the Hotplug functionality was invented.
Yes it was invented, yet thats already old technology. Nowadays, you scale horizontally and just spin up multiple machines to lighten the load.

I have to say that I've never seen hotplugging in any company I worked with/for and in any hypervisor (Hyper-V, VMware, XEN and KVM). The reason they told me is always that you have poor OS support and it is just not worth the hassle if something goes wrong, so you need to reboot anyway. Therefore, the geneal procedure is wait for a proper time then shutdown, change setting and startup again. They also said, and I concur, that you need to monitor the load and proactively schedule downtime for resources if you're not using an horizontally scaling architecture.
 
  • Like
Reactions: emptness
Yes it was invented, yet thats already old technology. Nowadays, you scale horizontally and just spin up multiple machines to lighten the load.

I have to say that I've never seen hotplugging in any company I worked with/for and in any hypervisor (Hyper-V, VMware, XEN and KVM). The reason they told me is always that you have poor OS support and it is just not worth the hassle if something goes wrong, so you need to reboot anyway. Therefore, the geneal procedure is wait for a proper time then shutdown, change setting and startup again. They also said, and I concur, that you need to monitor the load and proactively schedule downtime for resources if you're not using an horizontally scaling architecture.
You are undoubtedly right in your own way.
But still, sometimes using Hotplug is more convenient and justified)
 
Did you mean this Documentation?
Yes, this documentation.
To tell the truth, if you mean this item from the documentation, then it is incomprehensible to me.
Am I reasoning correctly in the previous post?

The CPU limit parameter limits the maximum usage of the hypervisor's physical cores? or are processor threads also taken into account? If my processor has 4 cores and 4 threads, then theoretically I can put CPU limit =8?

1700214076313.png
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!