Question about cpu usage rate for multiple apps running in one DEA

676 views
Skip to first unread message

tsjsdbd

unread,
Jun 4, 2014, 3:28:03 AM6/4/14
to vcap...@cloudfoundry.org
DEA get the cpu usage rate for an app by this code (compute_cpu_usage in stat_collector.rb):

used = @cpu_samples[1][:ns_used] - @cpu_samples[0][:ns_used] #CPU time obtained by this container 
elapsed = @cpu_samples[1][:timestamp_ns] - @cpu_samples[0][:timestamp_ns] #time have passed

 @computed_pcpu = used.to_f / elapsed # used / all


and the "used time" come from the cgroup file "cpuacct.usage". as i know, cgroup use the cpu share for all container. (and now it is 256 for all)

so my question is: could it possible for two app runnin in one DEA, and the cpu usage rate more than 50% ? (or three app, ceiling 33% for each one?)

we want scale out app instances by the cpu usage rate of this app, but i doubt this number is not precise.

any reply will be very appreciated


Matthew Sykes

unread,
Jun 4, 2014, 8:27:59 AM6/4/14
to vcap...@cloudfoundry.org
The cpu usage of an application instance can range from 0% (no CPU used) to the number of logical CPUs on the DEA * 100% (a multi-threaded app completely consuming all CPUs on the box).  This reporting is similar to the 'Irix' mode reporting used by top under Linux.

A single threaded app in a container can never use more than 1 CPU so it will have a usage between 0 and 100% but a multi-threaded app can use more than one CPU concurrently so it may consume more CPU time than wall-clock time.

The data comes directly from the cpu accounting subsystem of cgroups so it's relatively accurate but, depending on what you know about your deployment, it may not be actionable for scaling purposes.

To explicitly answer your question:

> could it possible for two app runnin in one DEA, and the cpu usage rate more than 50% ? (or three app, ceiling 33% for each one?)

Yes.


--
You received this message because you are subscribed to the Google Groups "Cloud Foundry Developers" group.
To view this discussion on the web visit https://groups.google.com/a/cloudfoundry.org/d/msgid/vcap-dev/22cc371a-e6df-429f-b491-f42ddd3a39a8%40cloudfoundry.org.

To unsubscribe from this group and stop receiving emails from it, send an email to vcap-dev+u...@cloudfoundry.org.



--
Matthew Sykes
matthe...@gmail.com
Message has been deleted

tsjsdbd

unread,
Jun 4, 2014, 10:36:54 PM6/4/14
to vcap...@cloudfoundry.org
thank you for your reply, learn a lot :-)
so if two same single threaded app running in one DEA(assume only one logical CPU), and they both greedy for the cpu, the average cpu usage for one app maybe 50%, am i right? 
and set 80% for scaling thresold is not appropriate

在 2014年6月4日星期三UTC+8下午8时27分59秒,Matthew Sykes写道:

Matthew Sykes

unread,
Jun 5, 2014, 9:19:19 AM6/5/14
to vcap...@cloudfoundry.org
so if two same single threaded app running in one DEA, and they both greedy for the cpu, the average cpu usage for one app maybe 50%, am i right? 

Only if your DEA has a single core processor with a single hardware thread.  

If your DEA has more than one CPU, both app instances will have a usage come back of ~100% because they will each end up consuming nearly one full CPU.

Later, as more and more application instances get deployed, the box utilization will approach its capacity so the cgroup cpu share will start to influence the distribution of cpu across the instances.  At that point you'll see the usage for your initial two instances start to drop since they're not getting as much CPU as they were when they were the only instances on the DEA.



On Wed, Jun 4, 2014 at 7:02 PM, tsjsdbd <tsj...@huawei.com> wrote:
thank you for your reply, learn a lot :-)
so if two same single threaded app running in one DEA, and they both greedy for the cpu, the average cpu usage for one app maybe 50%, am i right? 
and set 80% for scaling thresold is not appropriate


在 2014年6月4日星期三UTC+8下午8时27分59秒,Matthew Sykes写道:
The cpu usage of an application instance can range from 0% (no CPU used) to the number of logical CPUs on the DEA * 100% (a multi-threaded app completely consuming all CPUs on the box).  This reporting is similar to the 'Irix' mode reporting used by top under Linux.

To unsubscribe from this group and stop receiving emails from it, send an email to vcap-dev+u...@cloudfoundry.org.



--
Matthew Sykes
matthe...@gmail.com

Matthew Sykes

unread,
Jun 5, 2014, 8:57:43 PM6/5/14
to vcap...@cloudfoundry.org
Yes, the cpu utilization of each instance should approach 50%.



To unsubscribe from this group and stop receiving emails from it, send an email to vcap-dev+u...@cloudfoundry.org.



--
Matthew Sykes
matthe...@gmail.com

James Bayer

unread,
Jun 6, 2014, 8:50:20 AM6/6/14
to vcap...@cloudfoundry.org
one other note to this is that CF currently weights the CPU share for a given application container by the amount of memory allocated to the app [1].

so this means that apps that have been allocated more memory as assigned by the user, get a higher allocation of CPU as well.


To unsubscribe from this group and stop receiving emails from it, send an email to vcap-dev+u...@cloudfoundry.org.



--
Thank you,

James Bayer
Reply all
Reply to author
Forward
0 new messages