> -----Original Message----- > From: Rainer Jung [mailto:rainer.j...@kippdata.de] > Sent: Monday, May 18, 2009 11:10 PM > To: Tomcat Users List > Subject: Re: Running out of tomcat threads - why many threads in > RUNNABLEstage even with no activity > > On 19.05.2009 02:54, Caldarale, Charles R wrote: > >> From: Pantvaidya, Vishwajit [mailto:vpant...@selectica.com] > >> Subject: RE: Running out of tomcat threads - why many threads in > >> RUNNABLEstage even with no activity > >> > >> Ok - so then the question is when does tomcat transition the thread > >> from Running to Waiting? Does that happen after AJP drops that > >> connection? > > RUNNABLE and WAITING are thread states in the JVM. They don't relate in > general to states inside Tomcat. In this special situation they do. > > The states you observe are both completely normal in themselves. One > (the stack you abbreviate with RUNNABLE) is handling a persistant > connection between web server and Tomcat which could send more requests, > but at the moment no request is being processed, the other (you > abbreviate with WAITING) is available to be associated with a new > connection that might come in some time in the future. >
[Pantvaidya, Vishwajit] Thanks Rainer. The RUNNABLE thread - is it a connection between Tomcat and webserver, or between Tomcat and AJP? Is it still RUNNABLE and not WAITING because the servlet has not explicitly closed the connection yet (something like HttpServletResponse.getOutputStresm.close) > > > >> So could the problem be occurring here because AJP is holding on to > >> connections? > > > Sorry, I haven't been following the thread that closely. Not sure > > what the problem you're referring to actually is, but having a Tomcat > > thread reading input from the AJP connector is pretty normal. > > The same to me. What's the problem? AJP is designed to reuse connections > (use persistent connections). If you do not want them to be used for a > very long time or like those connections to be closed when being idle, > you have to configure the appropriate timeouts. Look at the timeouts > documentation page of mod_jk. > > In general your max thread numbers in the web server layer and in the > Tomcat AJP pool need to be set consistently. > [Pantvaidya, Vishwajit] My problem is that tomcat is running out of threads (maxthreadcount=200). My analysis of the issue is: - threads count is exceeded because of a slow buildup of RUNNABLE threads (and not because number of simultaneous http requests at some point exceeded max thread count) - most/all newly created TP-Processor threads are in RUNNABLE state and remain RUNNABLE - never go back to WAITING state (waiting for thread pool) - in such case, I find that tomcat spawns new threads when a new request comes in - this continues and finally tomcat runs out of threads - Setting connectionTimeout in server.xml seems to have resolved the issue - but I am wondering if that was just a workaround i.e. whether so many threads remaining RUNNABLE indicate a flaw in our webapp i.e. it not doing whatever's necessary to close them and return them to WAITING state. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org