You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Daryl Stultz <da...@6degrees.com> on 2009/02/24 21:50:50 UTC
Apache -> Tomcat connection problem
Hello,
I don't know if this is an Apache problem, Tomcat problem, both or neither.
Hopefully someone can point me in the right direction.
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
Tomcat AJP connector defaults to 200 for maxThreads. The site has 20
applications, each with 2 ProxyPass directives for ports 80 and 443. The
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 '1,2p;/8009/p' | wc -l
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?
Thanks.
--
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:daryl@6degrees.com
Re: Apache -> Tomcat connection problem
Posted by Daryl Stultz <da...@6degrees.com>.
On Thu, Feb 26, 2009 at 6:45 PM, Rainer Jung <ra...@kippdata.de>wrote:
> All problems described starting with comment #9 have been fixed by RĂ¼diger
> latest in revision 396050. Version 2.2.2 is revision 396066 so should
> include those fixes.
>
> This is starting to look more like an Apache issue, maybe I should move to
>> that list...
>>
>
> I think that's appropriate, but don't be astonished in case someone
> suggests updating ;)
>
Rainer, just an update: I changed my httpd.conf ProxyPass directives like
so:
ProxyPass /foo ajp://localhost:8009/foo/ ttl=600
and my Tomcat connector like this:
<Connector port="8009"
enableLookups="false" redirectPort="8443" protocol="AJP/1.3"
maxSpareThreads="50" maxThreads="200" minSpareThreads="4"
connectionTimeout="600000"
/>
So basically, specifying what are the documented defaults plus adding the
connectionTimeout.
Now the connections build up, drop down a little, build back up, etc. It
goes over 300 (150) from time to time but never goes high enough (350) to
trigger a graceful restart. So the system is stable though not behaving the
way I think it should. Not sure which part made the difference. I haven't
gotten to trying worker MPM yet. I tried dropping ttl to 300 with no
apparent difference in behavior.
Thanks for your help.
--
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:daryl@6degrees.com
Re: Apache -> Tomcat connection problem
Posted by Rainer Jung <ra...@kippdata.de>.
On 26.02.2009 22:35, Daryl Stultz wrote:
> It appears my last post didn't make it through some virus scanner (Antigen
> for Exchange found Body of Message infected with Exceeded Realtime Timeout
> virus.) Apologies if it made it to the list.
>
>
> On Tue, Feb 24, 2009 at 7:40 PM, Rainer Jung<ra...@kippdata.de>wrote:
>
>> smax Either 0 or 1. I would say 0 in order to get rid of idle
>> connections.
>>
>
> This is ignored for 2.2.2 (see
> https://issues.apache.org/bugzilla/show_bug.cgi?id=43371).
So fixed in 2.2.10.
>> connectiontimeout E.g. 5 or 10
>
>
> This produces an error: ProxyPass unknown Worker parameter.
Added in 2.2.10.
> Unfortunately, I'm not in a position to upgrade httpd as you recommend.
Many of the interesting proxy enhancements for httpd 2.x came with 2.2
and there were a couple of additions and fixes during the 2.2 releases.
So if you want to use proxy with balancing or with more detailed pool
configuration, you need to be able to upgrade httpd to a recent patch
level, this time and maybe again in the future.
> Should I try the worker MPM? I found this which suggests a bug has been
> fixed for worker MPM:
>
> https://issues.apache.org/bugzilla/show_bug.cgi?id=38227#c9
>
> This is a link right to James Robinson's description of his problem which
> seems pretty consistent with mine. Odd, though, the original poster switched
> from worker to prefork as a workaround and I'm considering the opposite, so
> probably not the solution for me. Comments?
All problems described starting with comment #9 have been fixed by
RĂ¼diger latest in revision 396050. Version 2.2.2 is revision 396066 so
should include those fixes.
> This is starting to look more like an Apache issue, maybe I should move to
> that list...
I think that's appropriate, but don't be astonished in case someone
suggests updating ;)
Regards,
Rainer
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Apache -> Tomcat connection problem
Posted by Daryl Stultz <da...@6degrees.com>.
It appears my last post didn't make it through some virus scanner (Antigen
for Exchange found Body of Message infected with Exceeded Realtime Timeout
virus.) Apologies if it made it to the list.
On Tue, Feb 24, 2009 at 7:40 PM, Rainer Jung <ra...@kippdata.de>wrote:
>
> smax Either 0 or 1. I would say 0 in order to get rid of idle
> connections.
>
This is ignored for 2.2.2 (see
https://issues.apache.org/bugzilla/show_bug.cgi?id=43371).
>
> connectiontimeout E.g. 5 or 10
This produces an error: ProxyPass unknown Worker parameter.
Unfortunately, I'm not in a position to upgrade httpd as you recommend.
Should I try the worker MPM? I found this which suggests a bug has been
fixed for worker MPM:
https://issues.apache.org/bugzilla/show_bug.cgi?id=38227#c9
This is a link right to James Robinson's description of his problem which
seems pretty consistent with mine. Odd, though, the original poster switched
from worker to prefork as a workaround and I'm considering the opposite, so
probably not the solution for me. Comments?
This is starting to look more like an Apache issue, maybe I should move to
that list...
--
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:daryl@6degrees.com
Re: Apache -> Tomcat connection problem
Posted by Daryl Stultz <da...@6degrees.com>.
On Tue, Feb 24, 2009 at 7:40 PM, Rainer Jung <ra...@kippdata.de>wrote:
>
> smax Either 0 or 1. I would say 0 in order to get rid of idle
> connections.
>
This is ignored for 2.2.2 (see
https://issues.apache.org/bugzilla/show_bug.cgi?id=43371).
>
> connectiontimeout E.g. 5 or 10
This produces an error: ProxyPass unknown Worker parameter.
Unfortunately, I'm not in a position to upgrade httpd as you recommend.
Should I try the worker MPM? I found this which suggests a bug has been
fixed for worker MPM:
https://issues.apache.org/bugzilla/show_bug.cgi?id=38227#c9
This is a link right to James Robinson's description of his problem which
seems pretty consistent with mine. Odd, though, the original poster switched
from worker to prefork as a workaround and I'm considering the opposite, so
probably not the solution for me. Comments?
This is starting to look more like an Apache issue, maybe I should move to
that list...
--
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:daryl@6degrees.com
Re: Apache -> Tomcat connection problem
Posted by Rainer Jung <ra...@kippdata.de>.
On 24.02.2009 23:31, Daryl Stultz wrote:
>> 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.
>>
>
> See Christopher's response. Do you know of the implementation being
> different than the docs?
No, he's right, but the sizing of the thread pool is so important that I
wouldn't only rely on the default. You always have to remember that and
it might change during upgrading or when switching to a different
connector implementation.
>> 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.
>>
>
> This is the part where expert advice comes in. I don't have any idea what
> "reasonable timeouts" are and the docs don't give a decent way to calculate
> it.
My personal opinion:
min Default 0 is fine.
max Default 1 is fine for prefork MPM (single threaded)
smax Either 0 or 1. I would say 0 in order to get rid of idle connections.
acquire Should be irrelevant for prefork.
connectiontimeout E.g. 5 or 10
ping I would activate this with a value of e.g. 10 (seconds)
ttl E.g. 600 (seconds). You should then set connectionTimeout on your
Tomcat connector to 600000 (milliseconds).
timeout Setting a timeout generally would make things more robust, but
you need to make sure, that nothing in your webapp responds slower than
this value (seconds).
Regards,
Rainer
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Apache -> Tomcat connection problem
Posted by Daryl Stultz <da...@6degrees.com>.
On Tue, Feb 24, 2009 at 4:56 PM, Rainer Jung <ra...@kippdata.de>wrote:
> You need to understand it.
> ...
> You can check your MPM by calling "httpd -V". The output will contain a
> line like
>
> -D APACHE_MPM_DIR="server/mpm/worker"
>
Server version: Apache/2.2.2
Server built: Jul 26 2006 11:12:08
Server's Module Magic Number: 20051115:2
Server loaded: APR 1.2.2, APR-Util 1.2.7
Compiled using: APR 1.2.2, APR-Util 1.2.7
Architecture: 32-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
>
> 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.
>
See Christopher's response. Do you know of the implementation being
different than the docs?
>
>
> 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.
>
Me neither, just trying to provide useful setup information. I have a total
of about 40 ProxyPass (mod_proxy_ajp) directives. I don't have any idea how
that impacts things.
>
> What's you platform?
Fedora Core release 5 (Bordeaux)
>
> 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.
>
Yes, I mentally accounted for the header lines. Leaving off the wc -l, I
have never seen anything but ESTABLISHED. I'll keep an eye on it.
>
> 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.
>
I'll look into that.
> 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.
>
This is the part where expert advice comes in. I don't have any idea what
"reasonable timeouts" are and the docs don't give a decent way to calculate
it.
Thanks.
--
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:daryl@6degrees.com
Re: Apache -> Tomcat connection problem
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Rainer,
On 2/24/2009 4:56 PM, Rainer Jung wrote:
> On 24.02.2009 21:50, Daryl Stultz wrote:
>> 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.
Maybe there is no default, but it is sure documented as such:
http://tomcat.apache.org/tomcat-5.5-doc/config/ajp.html
Docs for 'maxThreads' attribute:
"
The maximum number of request processing threads to be created by this
Connector, which therefore determines the maximum number of simultaneous
requests that can be handled. If not specified, this attribute is set to
200.
"
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkmkbzYACgkQ9CaO5/Lv0PDXxgCgoxfcryiulllcC1AsSZYbS0ZJ
r1gAnjJCWj45D0Yot5sGCLa6ZnUtto3k
=RM2B
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Apache -> Tomcat connection problem
Posted by Rainer Jung <ra...@kippdata.de>.
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