You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Shimol Shah <sh...@gmail.com> on 2006/09/08 21:53:43 UTC

Performance monitoring for web applications

Hi,

I am trying to look for a way to programmtically find CPU resources used and
memory used for indivudual web applications. I have given it many tries on
Google but only thing I could find was some third party tool vendors that
give solutions to performance monitoring. Instead what I am looking for is
the programmatic way of knowing CPU and memory usage by a particular web
application.

I would really appreciate if someone can point me to a right direction. I
can work it out form there.

Thanks,
Shimol.

Re: Performance monitoring for web applications

Posted by Michele Mazzucco <Mi...@ncl.ac.uk>.
You could also try this tool (I haven't used it):

http://www.hyperic.com/products/

It uses this library
http://www.hyperic.com/products/sigar.html
which can be downloaded from Sourceforge.

Michele

Michael Echerer wrote:
> Shimol Shah wrote:
> Hi,
>> Hi,
>>
>> I am trying to look for a way to programmtically find CPU resources used
>> and
>> memory used for indivudual web applications. I have given it many tries on
>> Google but only thing I could find was some third party tool vendors that
>> give solutions to performance monitoring. Instead what I am looking for is
>> the programmatic way of knowing CPU and memory usage by a particular web
>> application.
>>
>> I would really appreciate if someone can point me to a right direction. I
>> can work it out form there.
>>
>> Thanks,
>> Shimol.
>>
> Try the Java 5.0+ javax.management API:
> http://java.sun.com/j2se/1.5.0/docs/api/index.html?javax/management/package-summary.html
> http://download.java.net/jdk6/docs/jre/api/management/extension/com/sun/management/package-tree.html
> http://download.java.net/jdk6/docs/jre/api/management/extension/com/sun/management/OperatingSystemMXBean.html#getProcessCpuTime()
> 
> with Java 6.0 there might be more options:
> http://download.java.net/jdk6/docs/api/java/lang/management/OperatingSystemMXBean.html#getSystemLoadAverage()
> 
> and have a look at www.lamdaprobe.org and its sources to get an idea.
> Basically you can get the CPU time the process uses and can put it into
> relation to a period of time to get the relative CPU usage like
> lamdaprobe does it. However it'll be only the usage of the JVM process
> not all processes.
> No clue how to measure per thread and you'll have to find a way to map
> all http connector threads in use at each point in time to each webapps
> to get a sum of cpu times for a certain webapp and put it into relation
> to the overall process time. Maybe you could weave something before and
> after each connector thread with aspectJ to measure to time the thread
> was used or have your own implementation. Nevertheless this wouldn't
> measure the cpu time of that thread, too.
> For memory it'll be difficult, too. Probably you can measure all objects
> similar to what lamdaprobe does for the Httpsession object. Instead
> you'd have to measure all objects for one classloader. As you have one
> classloader per webapp, this could be what you want.
> I guess it'll be quite Tomcat and SunVM specific, if it works at all.
> 
> Cheers and good luck. Let us know if you found a way.
> Michael
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Performance monitoring for web applications

Posted by Martin Gainty <mg...@hotmail.com>.
be aware that in catalina.policy you will need to grant RuntimePermission, PropertyPermission as well as MBeanServerPermission to the classes ..for example
grant codeBase "file:${catalina.home}/-" 
{
 permission java.lang.RuntimePermission "getenv.CATALINA_HOME";
 permission java.lang.RuntimePermission "setenv.CATALINA_HOME";
  permission java.util.PropertyPermission "javax.management.MBeanServer", "read,write";
  permission javax.management.MBeanServerPermission "*";           
  permission javax.management.MBeanPermission "*", "*";
  permission javax.management.MBeanTrustPermission "register";  
};
NB:MBeanServerPermission consructor takes 2 args.. but the second parameter is unsupported 
HTH
Martin --

http://java.sun.com/j2se/1.5.0/docs/api/index.html?javax/management/package-summary.html
*********************************************************************
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.



----- Original Message ----- 
From: "Michael Echerer" <me...@tngtech.com>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Sunday, September 10, 2006 9:56 AM
Subject: Re: Performance monitoring for web applications


> Shimol Shah wrote:
> Hi,
>> Hi,
>> 
>> I am trying to look for a way to programmtically find CPU resources used
>> and
>> memory used for indivudual web applications. I have given it many tries on
>> Google but only thing I could find was some third party tool vendors that
>> give solutions to performance monitoring. Instead what I am looking for is
>> the programmatic way of knowing CPU and memory usage by a particular web
>> application.
>> 
>> I would really appreciate if someone can point me to a right direction. I
>> can work it out form there.
>> 
>> Thanks,
>> Shimol.
>> 
> Try the Java 5.0+ javax.management API:
> http://java.sun.com/j2se/1.5.0/docs/api/index.html?javax/management/package-summary.html
> http://download.java.net/jdk6/docs/jre/api/management/extension/com/sun/management/package-tree.html
> http://download.java.net/jdk6/docs/jre/api/management/extension/com/sun/management/OperatingSystemMXBean.html#getProcessCpuTime()
> 
> with Java 6.0 there might be more options:
> http://download.java.net/jdk6/docs/api/java/lang/management/OperatingSystemMXBean.html#getSystemLoadAverage()
> 
> and have a look at www.lamdaprobe.org and its sources to get an idea.
> Basically you can get the CPU time the process uses and can put it into
> relation to a period of time to get the relative CPU usage like
> lamdaprobe does it. However it'll be only the usage of the JVM process
> not all processes.
> No clue how to measure per thread and you'll have to find a way to map
> all http connector threads in use at each point in time to each webapps
> to get a sum of cpu times for a certain webapp and put it into relation
> to the overall process time. Maybe you could weave something before and
> after each connector thread with aspectJ to measure to time the thread
> was used or have your own implementation. Nevertheless this wouldn't
> measure the cpu time of that thread, too.
> For memory it'll be difficult, too. Probably you can measure all objects
> similar to what lamdaprobe does for the Httpsession object. Instead
> you'd have to measure all objects for one classloader. As you have one
> classloader per webapp, this could be what you want.
> I guess it'll be quite Tomcat and SunVM specific, if it works at all.
> 
> Cheers and good luck. Let us know if you found a way.
> Michael
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
>

Re: Performance monitoring for web applications

Posted by Michael Echerer <me...@tngtech.com>.
Shimol Shah wrote:
Hi,
> Hi,
> 
> I am trying to look for a way to programmtically find CPU resources used
> and
> memory used for indivudual web applications. I have given it many tries on
> Google but only thing I could find was some third party tool vendors that
> give solutions to performance monitoring. Instead what I am looking for is
> the programmatic way of knowing CPU and memory usage by a particular web
> application.
> 
> I would really appreciate if someone can point me to a right direction. I
> can work it out form there.
> 
> Thanks,
> Shimol.
> 
Try the Java 5.0+ javax.management API:
http://java.sun.com/j2se/1.5.0/docs/api/index.html?javax/management/package-summary.html
http://download.java.net/jdk6/docs/jre/api/management/extension/com/sun/management/package-tree.html
http://download.java.net/jdk6/docs/jre/api/management/extension/com/sun/management/OperatingSystemMXBean.html#getProcessCpuTime()

with Java 6.0 there might be more options:
http://download.java.net/jdk6/docs/api/java/lang/management/OperatingSystemMXBean.html#getSystemLoadAverage()

and have a look at www.lamdaprobe.org and its sources to get an idea.
Basically you can get the CPU time the process uses and can put it into
relation to a period of time to get the relative CPU usage like
lamdaprobe does it. However it'll be only the usage of the JVM process
not all processes.
No clue how to measure per thread and you'll have to find a way to map
all http connector threads in use at each point in time to each webapps
to get a sum of cpu times for a certain webapp and put it into relation
to the overall process time. Maybe you could weave something before and
after each connector thread with aspectJ to measure to time the thread
was used or have your own implementation. Nevertheless this wouldn't
measure the cpu time of that thread, too.
For memory it'll be difficult, too. Probably you can measure all objects
similar to what lamdaprobe does for the Httpsession object. Instead
you'd have to measure all objects for one classloader. As you have one
classloader per webapp, this could be what you want.
I guess it'll be quite Tomcat and SunVM specific, if it works at all.

Cheers and good luck. Let us know if you found a way.
Michael


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Performance monitoring for web applications

Posted by Santosh Puranshettiwar <sa...@wirkle.com>.
You could get them profiled though.

Leon Rosenberg wrote:
> I don't think that this is possible, simpy because all your webapps
> are running in one jvm, which is one process for the cpu. You could
> try to identify separate threads, but i'm sceptical that this works.
>
> regards
> Leon
>
> On 9/8/06, Shimol Shah <sh...@gmail.com> wrote:
>> Hi,
>>
>> I am trying to look for a way to programmtically find CPU resources 
>> used and
>> memory used for indivudual web applications. I have given it many 
>> tries on
>> Google but only thing I could find was some third party tool vendors 
>> that
>> give solutions to performance monitoring. Instead what I am looking 
>> for is
>> the programmatic way of knowing CPU and memory usage by a particular web
>> application.
>>
>> I would really appreciate if someone can point me to a right 
>> direction. I
>> can work it out form there.
>>
>> Thanks,
>> Shimol.
>>
>>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Performance monitoring for web applications

Posted by Leon Rosenberg <ro...@googlemail.com>.
I don't think that this is possible, simpy because all your webapps
are running in one jvm, which is one process for the cpu. You could
try to identify separate threads, but i'm sceptical that this works.

regards
Leon

On 9/8/06, Shimol Shah <sh...@gmail.com> wrote:
> Hi,
>
> I am trying to look for a way to programmtically find CPU resources used and
> memory used for indivudual web applications. I have given it many tries on
> Google but only thing I could find was some third party tool vendors that
> give solutions to performance monitoring. Instead what I am looking for is
> the programmatic way of knowing CPU and memory usage by a particular web
> application.
>
> I would really appreciate if someone can point me to a right direction. I
> can work it out form there.
>
> Thanks,
> Shimol.
>
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Performance monitoring for web applications

Posted by Leon Rosenberg <ro...@googlemail.com>.
Rethinking my previous reply I now think what you want is possible,
even hard to achive. But if you measure the time spent in each
application in an amount of time you will get relative CPU usage for
those webapps; now measuring the cpu time for the VM in the same
amount of time (for example by executing ps via Runtime.exec()) you
can recalculate your relative values to absolute values. Don't know
how accurate it will be. Reading /proc/stat for the jvm process would
be probably more accurate.

regards
Leon

On 9/8/06, Shimol Shah <sh...@gmail.com> wrote:
> Hi,
>
> I am trying to look for a way to programmtically find CPU resources used and
> memory used for indivudual web applications. I have given it many tries on
> Google but only thing I could find was some third party tool vendors that
> give solutions to performance monitoring. Instead what I am looking for is
> the programmatic way of knowing CPU and memory usage by a particular web
> application.
>
> I would really appreciate if someone can point me to a right direction. I
> can work it out form there.
>
> Thanks,
> Shimol.
>
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org