On 6/6/06, <b class="gmail_sendername">Kir Kolyshkin</b> &lt;<a href="mailto:kir@openvz.org">kir@openvz.org</a>&gt; wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
CPU limit is in per cent units. I.e. if your server has a single CPU,<br>use --cpulimit 10 to limit a VE to 10% of the CPU.<br><br>On a two-way SMP box max. value of cpulimit is 200. Say, if you want a<br>VE to use no more than one CPUs, use --cpulimit 100.
</blockquote><div><br><br>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.
<br><br>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?<br><br>Pradeep<br>&nbsp;</div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Pradeep Padala wrote:<br><br>&gt; Thanks for the explanation, but I DID use the --cpulimit parameter.<br>&gt;<br>&gt; I set the limit to 1000 units, I run a while(1) loop, and I see a 100%<br>&gt; loadavg on the host node. Shouldn't it be somewhere around 10% ?
<br>&gt;<br>&gt; Pradeep<br>&gt;<br>&gt; On 6/6/06, *Kir Kolyshkin* &lt;<a href="mailto:kir@openvz.org">kir@openvz.org</a> &lt;mailto:<a href="mailto:kir@openvz.org">kir@openvz.org</a>&gt;&gt;<br>&gt; wrote:<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; Looks like you misunderstand the concept of cpuunits. cpuunits is
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; not a<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; hard limit, but just a suggestion, and a CPU time is shared<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; proportionally to the values given. So, if you will have 9 VEs and the<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; host system with cpuunits set to 1000 for all of them, and run the
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; loop<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; in all of them, each VE will use 10% of the CPU time.<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; In case you will stop the loop running in 5 VEs so there will be 4<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; such<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; VEs (plus the host system) left, each of them will use 20% of the CPU.
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; So, all the CPU time is distributed between VEs which will need it,<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; according with their proportional cpuunits.<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; More to say, the concept of &quot;total CPU units&quot; is purely fiction,
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; and is<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; here just for the convenience. People do want to set CPU units is<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; terms<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; of processor's megaherts, and this is what cpuunits does. But in<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; fact it<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; is not a megaherts but just a relative weights. 
I.e. all the cpuunits<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; values are relative to each other, it doesn't matter what the actual<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; numbers are -- what matters is a number given to a VE in relation<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; to the<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; sum of all cpuweights (which is expressed as &quot;total CPU units&quot;
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; just for<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; the convenience).<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; So, cpuunits, if you do not oversell them, are a CPU guarantee, not a<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; limit. If you want CPU limit -- use cpulimit parameter.<br>&gt;<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; Pradeep Padala wrote:<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; Hi,<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; I am trying to measure the CPU utlilization of the VZ<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; containers, and<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; change the cpu share dynamically. I have poured over most of the
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; documentation, and looked at the code as well, and it seems like<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; there's no utility that can directly show the current CPU<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; utilization<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; of a container (some thing like 30% of CPU). A search on the
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; user list<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; got me a message, where someone suggested using loadavg.<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; However, It<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; seems like the loadavg is not showing the proper utilization (or<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; showing the total CPU utilization). This is what I am doing.
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; I setup a container with 1000 units limit (total CPU units:<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; ~10000). I<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; wrote a small do {; }while(1); loop and ran it in the container,<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; now I<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; do cat /proc/loadavg in both the container and on the host node.<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; Since, the container is only using 1000 units, I should see<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; something<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; like 100% loadavg in the container, and 10% loadavg in the hostnode.
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; But, I see 100% at both places. Am I doing something wrong? How do I<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; get the current cpu utilization of a container?<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; &gt; Thanks,<br><br></blockquote></div>