aspose file tools*
The moose likes Tomcat and the fly likes want to Identify the running service name in Tomcat which use 100% cpu usage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "want to Identify the running service name in Tomcat which use 100% cpu usage" Watch "want to Identify the running service name in Tomcat which use 100% cpu usage" New topic
Author

want to Identify the running service name in Tomcat which use 100% cpu usage

yatin baraiya
Ranch Hand

Joined: Jul 17, 2012
Posts: 30
Hi all,

My web-based Java EE application is based on the following technology:

Frame Work: Struts 2.0
Server: Tomcat 6.0
Front UI: JSP, JSTL/Struts tag, HTML
Database: Microsoft SQL Server 9.00.2047.00
Language: Core java, XML, XSLT.
Deployment server:Tomcat 6.0

Right now I'm facing the problem that some of process of my web application will consume more CPU usage. Sometimes my Tomcat server will use 100% CPU; that's why my PC hangs. I can't identify which process will cause this 100% CPU usage.

i had already check and use the all the following tools
http://inebium.com/post/visualvm-java-monitor-profile
http://www.dekho.com.au/realtime-monitoring-of-tomcat-cpu-and-memory-usage/
http://java-monitor.com/forum/install.php
j console

etc...
i had find many links through Google to get this ,but nothing any useful which give me the process name which cause 100% CPU usage.
I am expecting the following type of information in my solution

suppose one of my struts action java is:

public class TestAction extends OSAction
{

public String setDataInList() throws SQLServerException, Exception
{

//at here stuff of too much java code it will take time
return SUCCESS;
}

}

Now one of my jsp page button on-click will fire the above action (setDataInList).

Suppose we think that setDataInList action will cause 100% cpu usage.

Now i want this process name (action or any inside code process details) which cause the 100% CPU usage.is there any free tool available or any available free third party application which is useful in my case?please help me anybody?

Thanks in Advance
Yatin Baraiya


Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16250
    
  21

Struts actions are not processes. They run under process threads, which are obtained from the Tomcat request thread pool and are returned to that pool once the action is complete.

My first line of defense against runaway code is the debugger, which allows me to see what threads are running and to pause them. If I pause a runaway thread, the CPU usage would normally improve greatly, then return to 100% when the thread is resumed.


Customer surveys are for companies who didn't pay proper attention to begin with.
yatin baraiya
Ranch Hand

Joined: Jul 17, 2012
Posts: 30
Tim Holloway wrote:Struts actions are not processes. They run under process threads, which are obtained from the Tomcat request thread pool and are returned to that pool once the action is complete.

My first line of defense against runaway code is the debugger, which allows me to see what threads are running and to pause them. If I pause a runaway thread, the CPU usage would normally improve greatly, then return to 100% when the thread is resumed.


Ok thanks Tim Holloway,

yes, you are right new Thread is allocate for every new request,
ok Then my question is :is it possible to identify the process threads details which run my Struts actions request, In my case action name is "setDataInList" so is there available any utility (third party free api/any free tool which can be configure in tomcat/any jdk inbuilt utility example like jamp.exe] which give me the details process threads running for that action?.

and you talking about debugger. So can you tell me how it will useful for me? How can i use it in my case?can you share me any reference link for its configuration and user guide.

Regards
Yatin
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2435
    
  28

Taking a thread dump of the tomcat process will give you the stack trace of the current execution point of each thread. You can then search through the thread dump for your action class names. This will tell you which thread is executing your action class. Then you can attach a debugger and halt the thread that is executing your class to debug it.
yatin baraiya
Ranch Hand

Joined: Jul 17, 2012
Posts: 30
Jayesh A Lalwani wrote:Taking a thread dump of the tomcat process will give you the stack trace of the current execution point of each thread. You can then search through the thread dump for your action class names. This will tell you which thread is executing your action class. Then you can attach a debugger and halt the thread that is executing your class to debug it.


hi

how do i get the thread dump of the tomcat process?can you give me its process step?and how to attach a debugger?,Where can i find this debugger
yatin baraiya
Ranch Hand

Joined: Jul 17, 2012
Posts: 30
Hi all

i think Taking a thread dump of the tomcat process will not help in my case.is it possible to identify the process threads details which run for my Struts actions request( for example, here my action name is "setDataInList"), i want any free api/free tool which can be configure in tomcat/any java jdk inbuilt utility example like jamp.exe which give me the details of process threads running for the my action?.

As per my finding , i have use the following:
1.VisulaVm tool
2.YouKit Java Profiler
3.samurai.jar
4.java-monitor-probe [third party war file ,This application which can monitor our all deployed application status.]
5.jtda.jar

but from that nothing helpful for me.

If i am going to the wrong way, then please somebody guide me,any help regarding my question will be very appreciate for me?

Thanks & Regards
Yatin Baraiya

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16250
    
  21

Add Eclipse to your list and use its debugger.

There are other debuggers that would do the job as well (since Java uses a standard debug interface), but it's free and lots of people here know how to use it.
yatin baraiya
Ranch Hand

Joined: Jul 17, 2012
Posts: 30
Tim Holloway wrote:Add Eclipse to your list and use its debugger.

There are other debuggers that would do the job as well (since Java uses a standard debug interface), but it's free and lots of people here know how to use it.


hi Tim Holloway

yes i can use the Eclipse IDE as debugger.but Hear I can not use eclipse ide in my case, because i want to give the solution to my client ,and he don't know how to debug with eclipse, as well as eclipse is not installed in their PC, at there only tomcat server/java and other required software is installed and only J2ee based web application is deployed into tomcat 6.0 server, now what approach can be useful in my case?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16250
    
  21

If at all possible, you need to find a way to replicate this problem on a test machine. First, because in order to work on it, you'll probably have to do things that could be disruptive and dangerous to a production environment. Secondly, because once you find a fix, you should be able to confirm that the fix truly fixes things without making a guinea pig out of the customer.

However, Eclipse does not need to be installed on the client machine, regardless. All that's really necessary is that the client Tomcat should be started with remote debugging enabled and an open firewall connection from your Eclipse machine to that port. Although having an exact copy of the source code for the classes being run on the Tomcat server also helps immensely.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: want to Identify the running service name in Tomcat which use 100% cpu usage