tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rainer Jung <rainer.j...@kippdata.de>
Subject Re: Apache -> Tomcat connection problem
Date Tue, 24 Feb 2009 21:56:26 GMT
On 24.02.2009 21:50, Daryl Stultz wrote:
> I'm running Tomcat 5.5.17 behind Apache 2.2.2. I am connecting with a Tomcat
> AJP connector like so:
>
>   <Connector port="8009" enableLookups="false" redirectPort="8443"
> protocol="AJP/1.3" />
>
> and Apache ProxyPass like so:
>
> ProxyPass /myapp ajp://localhost:8009/myapp/
>
> Apache has the default number of connections set - MaxClients is either 256
> or 150, I don't understand the prefork/worker MPM thing. As above, the

You need to understand it.

prefork MPM: only uses processes, not multiple threads per process. Each 
request being processed occupies one process. Each process can only 
handle one rquest at a time. Scaling up and down via creating additional 
processes or stopping idle ones.

worker MPM: Uses multi-threaded processes, each with the same number of 
(configured) threads, by default 25. Each request being processed 
occupies one thread, each process can handle multiple threads 
concurrently (as many as you configured threads per process). Scaling up 
and down via creating additional processes or stopping idle ones.

winnt MPM: Only on windows. Uses two processes, one is a watchdog (it 
does also exist for prefork and worker) and the other one is highly 
multithreaded (default 150 threads) and does all the requests. Like 
worker with one fixed worker process using much more threads in this 
process. No scaling up and down.

You can check your MPM by calling "httpd -V". The output will contain a 
line like

  -D APACHE_MPM_DIR="server/mpm/worker"

> Tomcat AJP connector defaults to 200 for maxThreads. The site has 20

Defaults? I think no, and you haven't configured 200 in your abive 
config snippet.

> applications, each with 2 ProxyPass directives for ports 80 and 443. The

Hmm, not sure, how ports 80 and 443 with HTTP(s) proxying come into play 
now.

> general load on the site is low with 5 - 15 users on at any one time.
>
> This command here, I believe, counts the number of connections between
> Apache and Tomcat:
>
> netstat -tn | sed -n -e| wc -l

What's you platform?

The command counts LISTEN (the listening socket), the 2 header lines, 
all ESTABLISHED connections (those are the ones you are after) and e.g. 
also TIME_WAIT connections, all of them together. You need to count more 
specific.

Depending on your idle timeouts on the AJP connections, you might have 
many more TIME_WAITs than ESTABLISHED. For the idle timeouts, see the 
mod_proxy docs page for httpd and connectionTimeout for the Tomcat AJP 
connector. Consider upgrading httpd to 2.2.11, because mod_proxy_ajp was 
very new in 2.2.2 and there have been a couple of fixes after that version.

> The site has been running for a couple years, though the code changes and I
> continue to add new apps, it has been running fine. Now what seems to be
> happening is the number of connections between Apache and Tomcat grows at
> various rates from 4 or 10 or 20 after an Apache restart to 400 and more. At
> around 400 the site gets very sluggish. This seems to make some sense if
> Tomcat has maxThreads of 200 and the above command counts connections in
> both directions - TC is running out of connections. The question is why? I
> don't have enough users to warrant the connection pool growing like this. I
> currently have a cron task that does a graceful restart of Apache after 300
> connections. Can anyone shed some light on this or point me to some other
> resource for help?

First check, whether it is really ESTABISHED connections. Then configure 
reasonable timeouts as described in the mod_proxy documentation and an 
additional connectionTimeout for Tomcat.

Regards,

Rainer

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


Mime
View raw message