mod_jk: Expected behaviour for ajp-pool currentThreadCount

2008-12-12 Thread Michael Echerer
Hello,

I'm currently analysing issues with a quite old Tomcat 5.5.17, mod_jk
1.2.15 and Apache 2.0.55 loadbalanced setup with 4 Apaches (worker.c)
and 4 Tomcats.

Questions are:
* Can anyone explain why Apache SYN requests to Tomcat don't get
answered (probably this happens only if maxClients exceeds Tomcat AJP
pool sizes).
* Shouldn't the AJP thread pool shrink to maxSpareThreads, if idle, or
will threads stay open if Apache ever requested them?

Currently there are 4 Apaches, 2 with

StartServers 2
MaxClients 300
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild  0

and 2 more with

StartServers 2
MaxClients 200
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild  0

that have problems with hung SYN requests when getting near the 4
Tomcat's default AJP thread pool size of 200.

Current guess was that it's simply a bad idea to have 2*300+2*200=1000
maxClients on Apache side and just 4*200=800 AJP threads (if evenly
balanced) on Tomcat side.

So firstly increased Tomcat threads to maxThreads=500 to find some peak.
All other AJP connector settings are default, resp. not defined.

Meanwhile we log the JMX currentThreadCount for the AJP-Pools and the
thread count only increases. However even after peak hours the
currentThreadCount does not decrease. However would expect to get back
to the maxSpareThreads default of 50 during night time.

Can anyone explain why the AJP thread count stays high? I saw that one
could configure mod_jk connection_pool_timeout which is not done yet.
Could that be the reason for the thread pool never reducing the thread
count even though the AJP thread pool has a maxSpareThread setting (i.e.
doesn't this have an effect without pool timeout?)?

What could be the reason for SYN requests of the Apache that never get
answered by Tomcat?

Thanks,
Michael Echerer


-- 
TNG Technology Consulting GmbH, Betastr. 13a, D-85774 Unterföhring
Geschäftsführer: Henrik Klagges, Gerhard Müller, Christoph Stock
Amtsgericht München, HRB 135082

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: mod_jk: Expected behaviour for ajp-pool currentThreadCount

2008-12-12 Thread Bill Barker

Michael Echerer m...@tngtech.com wrote in message 
news:49426119.3060...@tngtech.com...
 Hello,

 I'm currently analysing issues with a quite old Tomcat 5.5.17, mod_jk
 1.2.15 and Apache 2.0.55 loadbalanced setup with 4 Apaches (worker.c)
 and 4 Tomcats.

 Questions are:
 * Can anyone explain why Apache SYN requests to Tomcat don't get
 answered (probably this happens only if maxClients exceeds Tomcat AJP
 pool sizes).

That is the most likely reason, but there are other possibilities that 
should show up in your Tomcat logs.

 * Shouldn't the AJP thread pool shrink to maxSpareThreads, if idle, or
 will threads stay open if Apache ever requested them?


With the default settings, the threads will stay open if Apache ever 
requested them.  With a version this old, you probably want to specify a 
connectionTimeout=xx in the Connector protocol=AJP/1.3 ... / 
element to allow threads to die if they aren't reused in a timely manor.  In 
this case, you probably also want to configure mod_jk to use CPING/CPONG so 
that it can detect that the thread went away.

Of course upgrading Tomcat makes available the APR and (experimental) NIO 
AJP/1.3 connectors, which allow a huge number of connections without tying 
up threads.

 Currently there are 4 Apaches, 2 with

 StartServers 2
 MaxClients 300
 MinSpareThreads 25
 MaxSpareThreads 75
 ThreadsPerChild 25
 MaxRequestsPerChild  0

 and 2 more with

 StartServers 2
 MaxClients 200
 MinSpareThreads 25
 MaxSpareThreads 75
 ThreadsPerChild 25
 MaxRequestsPerChild  0

 that have problems with hung SYN requests when getting near the 4
 Tomcat's default AJP thread pool size of 200.

 Current guess was that it's simply a bad idea to have 2*300+2*200=1000
 maxClients on Apache side and just 4*200=800 AJP threads (if evenly
 balanced) on Tomcat side.


With the default settings, yes this is a bad idea ;).  You need to have at 
least as many AJP threads as maxClients+1 in the default case.

 So firstly increased Tomcat threads to maxThreads=500 to find some peak.
 All other AJP connector settings are default, resp. not defined.

 Meanwhile we log the JMX currentThreadCount for the AJP-Pools and the
 thread count only increases. However even after peak hours the
 currentThreadCount does not decrease. However would expect to get back
 to the maxSpareThreads default of 50 during night time.


See above.  The thread count will never go down without specifying a 
connectionTimeout.

 Can anyone explain why the AJP thread count stays high? I saw that one
 could configure mod_jk connection_pool_timeout which is not done yet.
 Could that be the reason for the thread pool never reducing the thread
 count even though the AJP thread pool has a maxSpareThread setting (i.e.
 doesn't this have an effect without pool timeout?)?


I've never tried to do this on the mod_jk side, but the archives suggest it 
doesn't work well.

 What could be the reason for SYN requests of the Apache that never get
 answered by Tomcat?


That the thread-pool is exhausted is the most common reason.  But since the 
default AJP Connector answers the request on the current thread and spawns 
another thread to go back and listen for connections there are other reasons 
(e.g. an OOME when spawning the thread) why it might fail.  However it 
should say in the Tomcat logs what the problem is.

 Thanks,
 Michael Echerer


 -- 
 TNG Technology Consulting GmbH, Betastr. 13a, D-85774 Unterföhring
 Geschäftsführer: Henrik Klagges, Gerhard Müller, Christoph Stock
 Amtsgericht München, HRB 135082 




-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org