subuk / vmango

Your own personal IaaS cloud
https://vmango.org
MIT License
329 stars 55 forks source link

hard limit the CPU allowance to X percent #4

Closed Shashwatsh closed 6 years ago

Shashwatsh commented 7 years ago

How do i limit the CPU allowance to 25% of a single core (for example: 1 ghz of physical 4gz core) is there a way to hard limit this?

subuk commented 7 years ago

It is a rare case, but if you really want, you can do it via <cputune> element and if statements inside domain xml template. Something like:

<domain>
...
    <cputune>
    {{ if eq .Plan.Name "small" }}
        <shares>512</shares>
    {{ else }}
        <shares>1024</shares>
    {{ end }}
    <cputune>
...
</domain>

http://libvirt.org/formatdomain.html#elementsCPUTuning https://vmango.org/docs/configuration/hypervisor/#machine-templates https://golang.org/pkg/text/template/

Shashwatsh commented 7 years ago

ok i read the docs but still does 512 shares mean 50% of the CPU?

subuk commented 7 years ago

The short answer is 'no' :) You should look into period and quota.

Shashwatsh commented 7 years ago

so technically, shares is soft limit and hard limit is quota / period so, if i want 25% of the CPU then i could do quota to 25000 and period to 100000. am i correct?

subuk commented 7 years ago

Yes, for hard limits you need to use quota and period, but I cant provide you any hints about it, because I have never used this feature.

subuk commented 6 years ago

So, I think this issue has been resolved.

Shashwatsh commented 6 years ago

Indeed, apologies for not closing this issue i didn't notice it.