CPU allocation

Davesc63

New Member
Jan 7, 2024
2
0
1
Hi all,

I have an N100 device (4 cores) and currently have the following guests:
- home assistant - 1 cpus
- opnsense 2 cpus
- Ubuntu lxc - 1 cpu

I just reduced these down to what felt like a minimum allocation since each VM is using up to about 10% cpu during load

However, it now seems like my power consumption has increased and the cpu usage graph is spiky. Kind of inverse to what I expected

Previously I just gave all VMs 4x cpu and “host” type.

What’s the rule of thumb here?

Thank you
 
My rule of thumb (or default if no other reason) is generally 4 for machines that will run interactive loads or compiling code, 2 for servers, and 1 for containers. Then keep an eye on it and increase/decrease as needed.

I'm not sure that "spiky" CPU usage is necessarily bad. Most workloads tend to be spiky. Over-allocating your cores as you describe will mean only 1 VM at a time can run. If that means less work actually getting done with some cores being idle then it makes sense that cpu would be less "spiky". Just a guess though.

Did you actually measure your power or the CPU temps, or is this more of a "gut feeling" or something?
 
I’m using a smart switch to monitor the power consumption.

So with the reduced cpu allocations I’m now seeing power consumption jump from 8w to 20w for the same workloads.

With the previous, more generous, cpu allocations the power consumption at the wall was a more consistent 8w to 11w
 
No idea about the power really. Can your switch measure an average over five minutes or something? If the CPU usage is more spiky so will the power be but maybe the average hasn't changed much? Just spit-balling here.

ETA: The conventional wisdom is that it is bad to allocate all of your cores to a single VM. Oversubscribing overall is ok (depending on workloads) since that is kind of an important use-case of virtualization, but having all cores on 1 CPU is supposed to make the scheduler's job harder and reduce overall throughput. I have not tested this personally.
 
Last edited: