Hi.On our production server (Suse Linux) we run a Tomcat server. Fromtime to time, our users tell us, that our web application is runningslow.Starting the command "top" I see that one Tomcat-Process is runningconsuming a lot of process time from the server. So I know the processID of the thread, but how can I match the PID to a Tomcat Thread?I have also tried to do a Java dump but I was not able to find theaccording Tomcat Thread.Is there a way to get the right Tomcat Thread from the process ID?Or is there a way from within a Tomcat Thread to get its process ID?I have searched in Google but I didn't found any answer to thisproblem ...Please Help, Thanks.Thomas Konrath
|
|
0
|
|
|
|
Reply
|
tkonrath (4)
|
4/19/2007 8:32:50 AM |
|
tkonrath@gmx.at wrote:> Hi.> > On our production server (Suse Linux) we run a Tomcat server. From> time to time, our users tell us, that our web application is running> slow.> > Starting the command "top" I see that one Tomcat-Process is running> consuming a lot of process time from the server. So I know the process> ID of the thread, but how can I match the PID to a Tomcat Thread?> > I have also tried to do a Java dump but I was not able to find the> according Tomcat Thread.> > Is there a way to get the right Tomcat Thread from the process ID?> Or is there a way from within a Tomcat Thread to get its process ID?> > I have searched in Google but I didn't found any answer to this> problem ...I found "How to generate a Thread Dump"<http://qa.netbeans.org/bugzilla/generating-thread-dumps.html>I tested the StackTrace tool (the JNLP link near the bottom of that page),and successfully grabbed a Java ThreadDump of a large Java-server-processrunning on my Linux.(Remember that your Tomcat-process is probably running with user-id root.You therefore need to run your browser from root, so that the launchedJavaWS-application will run from root too, and hence has permission fordumping the Tomcat-process.)You should get the stack traces of all Tomcat threads. Watch out for busythreads, i.e. the ones not idling in method Object.wait() orThread.sleep() .-- Thomas
|
|
0
|
|
|
|
Reply
|
Thomas
|
4/19/2007 3:17:18 PM
|
|
On Apr 19, 4:17 pm, Thomas Fritsch <i.dont.like.s...@invalid.com>wrote:>> I tested the StackTrace toolAh, thanks for the link : it does a little bit more than simplydumping the threads. It may be handy.> (Remember that your Tomcat-process is probably running with user-id root.> You therefore need to run your browser from root, so that the launched> JavaWS-application will run from root too, and hence has permission for> dumping the Tomcat-process.)No no no! A production server running Tomcat as root is avery bad idea.On Linux not only can you run Tomcat as a non-rootuser but you can also install the whole JDK as a non-rootuser (on Windows last time I checked you needed tohave admin privs to install Java).I said "can" though I really meant "should".It is trivial on a Linux system to have a non-privileged processlisten to a port > 1024 (a non-privileged can't listen on port <1024)and then have the stateful firewall transparently redirect requeststo the non-privileged port.If a production Tomcat on a Linux server is "probably runningas root" then something is very wrong :-/Not a single security conscious Unix admin would everallow this for a production server.Talk to you soon on c.l.j.p., Alex
|
|
0
|
|
|
|
Reply
|
alexandre_paterson
|
4/19/2007 11:01:14 PM
|
|
On Apr 19, 9:32 am, tkonr...@gmx.at wrote:....> On our production server (Suse Linux) we run a Tomcat server. From> time to time, our users tell us, that our web application is running> slow.How many users? How slow? Do you think you're hitting somekind of I/O bottleneck (network / disk) or do you think it's more ofa performance problem in the way the Webapp is programmed?> Starting the command "top" I see that one Tomcat-Process is running> consuming a lot of process time from the server. So I know the process> ID of the thread,No, you don't know the process ID of the thread. You know the processID of the Tomcat process.> but how can I match the PID to a Tomcat Thread?If you're running a non-antique Linux version there's noone-to-one mapping between threads and processes. Itused to be like this in kernel 2.4 non-NPTL and older...But it's not like that anymore.> I have also tried to do a Java dump but I was not able to find the> according Tomcat Thread.Is it always slow or only occasionally? Did you allocate a lot ofmemory to Tomcat? (if so the GC kicking in may wreak havocand you'd be better to reconfigure the type of GC used)Depending on why you're experiencing slowdown, you maybe better with a Java Webserver using multiplexing and NIO.Many people are saying good things about Resin.Of course the best Java Web server in the world won'tdo much good if the slowness is due to a problem inthe way the Webapp itself is programmed.If it was to me I'd first try to reproduce the problemin a similar environment: install same Linux + JDK +Tomcat + Webapp then do some load-testing to tryto see what's going on.The best, non-intrusive, way to do real-time profilingon a production server would be to run DTrace on(Open)Solaris... But you'll have to wait some morebefore that tool (and its Java probes) are ported toLinux.Good luck on finding the bottleneck and don'thesitate to report once you solve the problem,AlexP.S: you may want to play with the memory settingsof the JVM and Tomcat's server.xml and see if it helps.
|
|
0
|
|
|
|
Reply
|
alexandre_paterson
|
4/19/2007 11:28:17 PM
|
|
tkonrath@gmx.at wrote:> Hi.> > On our production server (Suse Linux) we run a Tomcat server. From> time to time, our users tell us, that our web application is running> slow.> > Starting the command "top" I see that one Tomcat-Process is running> consuming a lot of process time from the server. So I know the process> ID of the thread, but how can I match the PID to a Tomcat Thread?Processes are not the same thing as threads. By using top you have the process ID of the process that contains multiple threads for Tomcat. If you kill that process all the threads go away. You may need to look into how OSes work when you have some spare time after fixing this problem. Without the tool mentioned by Thomas you won't be able to determine the individual Tomcat thread identifiers (if there are any to begin with) unless you wanted to hack the kernel to provide that information.> > I have also tried to do a Java dump but I was not able to find the> according Tomcat Thread.> > Is there a way to get the right Tomcat Thread from the process ID?No because you don't have further information to go on to determine which thread within that process is the one you want. The process contains multiple threads and the process ID is just a number that only matches up with the process, hence the name.> Or is there a way from within a Tomcat Thread to get its process ID?> > I have searched in Google but I didn't found any answer to this> problem ...> > Please Help, Thanks.> > Thomas Konrath>
|
|
0
|
|
|
|
Reply
|
Brandon
|
4/20/2007 12:00:03 AM
|
|
alexandre_paterson@yahoo.fr wrote:> >>(Remember that your Tomcat-process is probably running with user-id root.>>You therefore need to run your browser from root, so that the launched>>JavaWS-application will run from root too, and hence has permission for>>dumping the Tomcat-process.)> > > No no no! A production server running Tomcat as root is a> very bad idea.Aha, good to know!But even then it might be necessary to run the StackTrace tool from the same user-id as the tomcat process (in order to have the permission for dumping the process).> > On Linux not only can you run Tomcat as a non-root> user but you can also install the whole JDK as a non-root> user (on Windows last time I checked you needed to> have admin privs to install Java).> > I said "can" though I really meant "should".> > It is trivial on a Linux system to have a non-privileged process> listen to a port > 1024 (a non-privileged can't listen on port <> 1024)> and then have the stateful firewall transparently redirect requests> to the non-privileged port.> > If a production Tomcat on a Linux server is "probably running> as root" then something is very wrong :-/> > Not a single security conscious Unix admin would ever> allow this for a production server.-- Thomas
|
|
0
|
|
|
|
Reply
|
Thomas
|
4/20/2007 8:07:26 AM
|
|
Here is a shell script to take and save thread dump in a text file. I have written a shell script to take the thread dump automatically.
visit : http://www.technotechi.com/2012/12/shell-script-to-perform-thread-dump.html
It might help you.
|
|
0
|
|
|
|
Reply
|
ajay.singhes (16)
|
2/21/2013 6:15:04 AM
|
|
|
6 Replies
555 Views
(page loaded in 0.248 seconds)
Similiar Articles: Hox to match Linux PID to tomcat thread - comp.lang.java ...Hi.On our production server (Suse Linux) we run a Tomcat server. Fromtime to time, our users tell us, that our web application is runningslow.Starting... How to start jboss as background process - comp.unix.solaris ...Hox to match Linux PID to tomcat thread - comp.lang.java ... How to start jboss as background process - comp.unix.solaris ... background pid number - comp.unix.shell ... pid of a process in background - comp.unix.shellHow to get Tomcat thread stack dump - comp.infosystems.www.servers ... Hox to match Linux PID to tomcat thread - comp.lang.java ... How to start jboss as background ... How do get a timer in a thread? - comp.unix.programmerHox to match Linux PID to tomcat thread - comp.lang.java ... Hi.On our production server (Suse Linux) we run a Tomcat server. Fromtime to time, our users tell us, that our ... Delete line above and below the line which matches a pattern ...awk: bailing out near line 1 - comp.lang.awk Hox to match Linux PID to tomcat thread - comp.lang ... out for busythreads, i.e. the ones not ... delete one line ... background pid number - comp.unix.shellGetting the PID of a process ID - comp.os.linux.misc How to get Tomcat thread stack dump - comp.infosystems.www.servers ..... jboss as background process - comp.unix ... Integrating Google Maps in Java Swing application - comp.lang.java ...B2B Marketplace - Mixet.se Media Center - comp.programming.threads ... B2B Marketplace - Mixet.se Media Center Follow how to send control-break or ctrl-c signal to background process ...How to get Tomcat thread stack dump - comp.infosystems.www.servers ... command: sendsignal PID, where PID is the process id ... ... break the ... showed me that standard Linux ... How to check whether malloc has allocated memory properly in case ...Last thing I could see from top commnd (Linux) after ... may have misunderstood Keith's post else-thread, but it ... types I think), and I remember getting things to match ... Sampling: What Nyquist Didn't Say, and What to Do About It - comp ...My current Linux rxvt terminal setting is let ... gladly refund the money that I (wasn't) paid ... has a number of tweakable options in how loosely the features must match to ... Hox to match Linux PID to tomcat thread - comp.lang.java ...Hi.On our production server (Suse Linux) we run a Tomcat server. Fromtime to time, our users tell us, that our web application is runningslow.Starting... Hox to match Linux PID to tomcat thread - Velocity Reviews ...Hi. On our production server (Suse Linux) we run a Tomcat server. From time to time, our users tell us, that our web application is running slow. Starting the command ... 7/22/2012 11:49:13 AM
|