R: Tomcat CPU 100%

2008-05-07 Thread Andrea Di Muro
Andrea Di Muro wrote:
| Hello everyone, I have a Tomcat server with several domains configured 
| and sometimes I can see that the tomcat process uses 100-190% (dual
| processor) and hangs up.
| I think that one of my customer has uploaded a jsp page that makes an 
| infinite loop.
| How can I check which page causes the problem?

Take a thread dump (QUIT signal on *NIX, CTRL-BREAK on windows console,
jstack in recent JVM implementations, ... some monitoring programs have this
ability, too) and look at what is running. You may have to run a couple of
them and compare. The thread that is always running the same thing is likely
to be the one that is causing problems.

- -chris


Tomcat it's running on a Linux Server, what is the exact command to take the
thread dump?
kill -s QUIT tomcat_pid is right?

By using this command will Tomcat shut down or just print the threa dump on
the standard output?
And how can I interpretate the output to see which page is causing the
problem?
Thank you

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



Re: R: Tomcat CPU 100%

2008-05-07 Thread Christopher Schultz

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Andrea,

Andrea Di Muro wrote:
| Tomcat is running on a Linux Server, what is the exact command to take the
| thread dump?
| kill -s QUIT tomcat_pid is right?

Yes. The thread dump will be printed on stdout, and probably go into
catalina.out.

| By using this command will Tomcat shut down or just print the threa
dump on
| the standard output?

Only the thread dump -- Tomcat will not shutdown.

| And how can I interpret the output to see which page is causing the
| problem?

A thread dump is like a stack trace, except that it performs a stack
trace on /all/ live threads. It will tell you what each thread is doing.

If you see a few threads that are running methods like _jsp_service,
then those threads are running JSPs. The name of the JSP should be
evident from the class and method name printed in the trace for that
particular thread.

You could observe several thread dumps to see if one particular thread
(or several) are always executing the same method. If so, that JSP is
probably the one that is hanging.

Good luck,
- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgh3xAACgkQ9CaO5/Lv0PBBbACgnRz2dQEdZH/kwzUXa/E/UjGE
n58AoIpHKTrJowHF+DmUwztHEfRF4ppa
=B4jY
-END PGP SIGNATURE-

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



Re: R: Tomcat CPU 100%

2008-05-07 Thread Juha Laiho

Christopher Schultz wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Andrea,

Andrea Di Muro wrote:
| Tomcat is running on a Linux Server, what is the exact command to 
take the

| thread dump?
| kill -s QUIT tomcat_pid is right?

Yes. The thread dump will be printed on stdout, and probably go into
catalina.out.

| By using this command will Tomcat shut down or just print the threa
dump on
| the standard output?

Only the thread dump -- Tomcat will not shutdown.

| And how can I interpret the output to see which page is causing the
| problem?

A thread dump is like a stack trace, except that it performs a stack
trace on /all/ live threads. It will tell you what each thread is doing.

If you see a few threads that are running methods like _jsp_service,
then those threads are running JSPs. The name of the JSP should be
evident from the class and method name printed in the trace for that
particular thread.

You could observe several thread dumps to see if one particular thread
(or several) are always executing the same method. If so, that JSP is
probably the one that is hanging.



Another (perhaps Linux-specific?) way to get some information is to run
ps -fLp 12345 (where 12345 should be the PID of your Tomcat process).
This will show one line for each thread in the Tomcat process, and also
will show the amount of CPU time used by each thread. If you run this
a couple of times, you should be able to pick up threads with significant
increase in the used CPU time. These can then be correlated with the
thread dump. F.ex. in my toy machine, the thread taking the most of
CPU time is:
tomcat7035 1  7870  0   40 Feb13 ?01:08:37 
/usr/lib/jvm/java/bin

... where 7035 is the process id of Tomcat, and 7870 is the thread id.

The thread dump then tells what that thread is running - however, the
thread dump lists threads by hexadecimal id, and the above is decimal,
so a conversion is needed: 7870=0x1ebe . Now to look for that 1ebe
in the thread dump:

ContainerBackgroundProcessor[StandardEngine[Catalina]] daemon prio=1 
tid=0x08366728 nid=0x1ebe waiting on condition [0xb135c000..0xb135cfa0]

   at java.lang.Thread.sleep(Native Method)
   at 
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1597)

   at java.lang.Thread.run(Thread.java:595)

 so, on this machine (a toy, as I said), the thread with most 
accumulated

CPU usage has been ContainerBackgroundProcessor - which was sleeping
at the time of this thread dump. For active request processing threads the
dump will differ a lot from the above, and will tell in which class/method
the thread is executing.
--
..Juha

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