[Users] Measuring and Adjusting CPU utilization

Kirill Korotaev dev at sw.ru
Wed Jun 7 04:20:05 EDT 2006


> Thanks ! This solved the problem. However, I still see the loadavg at 
> 100% (got from cat /proc/loadavg), but if I run top and see the CPU% for 
> the one particular application (while(1) loop), it is limited to 10% CPU.
This is also correct, since load average means 'average number of 
processes in running + uninterruptible state'. Since you busy loop is 
constantly in running state, it is accounted as 1.0 in loadavg.

> I can add up the CPU% for all the processes running in the container, 
> and can get the current % utilization of the container. Is there a 
> better way to do this?
Sorry, didn't got what you mean... Probably you ask how to calculate the 
amount of CPU being consumed by VPS in %?
To do so, you need to monitor /proc/vz/vestat file.
http://forum.openvz.org/index.php?t=msg&goto=2790&&srch=vestat#msg_2790

Thanks,
Kirill

> Pradeep
>  
> 
>     Pradeep Padala wrote:
> 
>      > Thanks for the explanation, but I DID use the --cpulimit parameter.
>      >
>      > I set the limit to 1000 units, I run a while(1) loop, and I see a
>     100%
>      > loadavg on the host node. Shouldn't it be somewhere around 10% ?
>      >
>      > Pradeep
>      >
>      > On 6/6/06, *Kir Kolyshkin* <kir at openvz.org
>     <mailto:kir at openvz.org> <mailto:kir at openvz.org <mailto:kir at openvz.org>>>
>      > wrote:
>      >
>      >     Looks like you misunderstand the concept of cpuunits.
>     cpuunits is
>      >     not a
>      >     hard limit, but just a suggestion, and a CPU time is shared
>      >     proportionally to the values given. So, if you will have 9
>     VEs and the
>      >     host system with cpuunits set to 1000 for all of them, and
>     run the
>      >     loop
>      >     in all of them, each VE will use 10% of the CPU time.
>      >
>      >     In case you will stop the loop running in 5 VEs so there will
>     be 4
>      >     such
>      >     VEs (plus the host system) left, each of them will use 20% of
>     the CPU.
>      >     So, all the CPU time is distributed between VEs which will
>     need it,
>      >     according with their proportional cpuunits.
>      >
>      >     More to say, the concept of "total CPU units" is purely fiction,
>      >     and is
>      >     here just for the convenience. People do want to set CPU units is
>      >     terms
>      >     of processor's megaherts, and this is what cpuunits does. But in
>      >     fact it
>      >     is not a megaherts but just a relative weights. I.e. all the
>     cpuunits
>      >     values are relative to each other, it doesn't matter what the
>     actual
>      >     numbers are -- what matters is a number given to a VE in relation
>      >     to the
>      >     sum of all cpuweights (which is expressed as "total CPU units"
>      >     just for
>      >     the convenience).
>      >
>      >     So, cpuunits, if you do not oversell them, are a CPU
>     guarantee, not a
>      >     limit. If you want CPU limit -- use cpulimit parameter.
>      >
>      >     Pradeep Padala wrote:
>      >
>      >     > Hi,
>      >     >
>      >     > I am trying to measure the CPU utlilization of the VZ
>      >     containers, and
>      >     > change the cpu share dynamically. I have poured over most
>     of the
>      >     > documentation, and looked at the code as well, and it seems
>     like
>      >     > there's no utility that can directly show the current CPU
>      >     utilization
>      >     > of a container (some thing like 30% of CPU). A search on the
>      >     user list
>      >     > got me a message, where someone suggested using loadavg.
>      >     However, It
>      >     > seems like the loadavg is not showing the proper
>     utilization (or
>      >     > showing the total CPU utilization). This is what I am doing.
>      >     >
>      >     > I setup a container with 1000 units limit (total CPU units:
>      >     ~10000). I
>      >     > wrote a small do {; }while(1); loop and ran it in the
>     container,
>      >     now I
>      >     > do cat /proc/loadavg in both the container and on the host
>     node.
>      >     > Since, the container is only using 1000 units, I should see
>      >     something
>      >     > like 100% loadavg in the container, and 10% loadavg in the
>     hostnode.
>      >     > But, I see 100% at both places. Am I doing something wrong?
>     How do I
>      >     > get the current cpu utilization of a container?
>      >     >
>      >     > Thanks,
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Users mailing list
> Users at openvz.org
> https://openvz.org/mailman/listinfo/users



More information about the Users mailing list