Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Apache Tomcat »

Re: Apache mod_jk memory leak?

Rainer Jung

2007-01-17

Replies:

JNeuhoff wrote:
> Yesterday, I indeed upgraded another server box to Apache 2.0.59, mod_jk
> 1.2.20, Tomcat 5.5.17, and also set the connection_pool_timeout=600 (is that
> value 600 seconds, or milliseconds?). I then subjected this server to a
> brief stresstest (roughly 50 simultanious HTTP sessions on Tomcat's end) and
> noticed the following:

Good, the value is in seconds, and the info has been added to the docs
for 1.2.21 a few days ago and to the online docs also :) Most other
timeouts are milliseconds though, but for the other ones the correct
info is already in the docs.

> Of the two 'Apache.exe' processes running under the Apache2 NT service, one
> grew in memory usage quickly from an initial 12MB to nearly 65MB, and stayed
> at that level overnight, even though there were no further requests made to
> that server since yesterday. I also noticed that a simple 'netstat -a'
> reported 35 established connections:
>
> <<
> TCP   DAOHPRW2:1682       DAOHPRW2.essex.ac.uk:8009 ESTABLISHED
> TCP   DAOHPRW2:4240       DAOHPRW2.essex.ac.uk:8009 ESTABLISHED
> TCP   DAOHPRW2:4241       DAOHPRW2.essex.ac.uk:8009 ESTABLISHED
> .....
>
> and another 35 established connection the opposite direction:
>
> <<
> TCP   DAOHPRW2:8009       DAOHPRW2.essex.ac.uk:1682 ESTABLISHED
> TCP   DAOHPRW2:8009       DAOHPRW2.essex.ac.uk:4240 ESTABLISHED
> TCP   DAOHPRW2:8009       DAOHPRW2.essex.ac.uk:4241 ESTABLISHED
> ....
>
> So, are the connections managed by mod_jk between Apache2 and Tomcat not
> released from the connection pool, despite the connection_pool_timeout=600?

By default apache will use as max number of connections the same value,
as the max number of threads, so that each thread can get it's own
connection. By default it will shrink the connection pool down to half
of the max size. There is a min value you can configure if this doesn't
fit your needs.

> Ideally I'd like to set an upper limit of lets say 200 concurrent HTTP
> Sessions for Tomcat, but I am not sure how exactly to configure the various
> timeout values and limits for mod_jk and Apache accordingly. Our Tomcat
> service makes MySQL queries and it can take at times a few seconds for
> generating a response. Does Apache2 use just one child process handling all
> requests or connections?

Yes, the Windows MPM has one observer process and a second one, that
handles all the requests. If you are really low on server ressources,
you can shrink you connection pool from 250 (equals number of threads
you configured) to 200 and set the minimum to something like 10. You
should also consider a connect_timeout (e.g. 15000) and a
prepost_timeout (e.g. 10000).

Let us know, if your crashes/hangs still show up with the new setup.

Regards,

Rainer

>
> J.Neuhoff
>
>
>
>
> P.S.
> At the moment our server is configured like that:
>
> httpd.conf:
>
> <<
> ....
> Timeout 300
> KeepAlive On
> MaxKeepAliveRequests 100
> KeepAliveTimeout 15
> # WinNT MPM
> # ThreadsPerChild: constant number of worker threads in the server process
> # MaxRequestsPerChild: maximum number of requests a server process serves
> <IfModule mpm_winnt.c>
> ThreadsPerChild 250
> MaxRequestsPerChild 0
> </IfModule>
> ....
> ### mod_jk 1.x configuration for connecting to Tomcat 5.5
> LoadModule   jk_module modules/mod_jk.so
> JkWorkersFile "C:/Program Files/Apache Software Foundation/Tomcat
> 5.5/conf/workers.properties"
> JkLogFile   "C:/Program Files/Apache Software Foundation/Tomcat
> 5.5/logs/mod_jk.log"
> JkLogLevel   info
> JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
> JkOptions   +ForwardKeySize +ForwardURICompat -ForwardDirectories
> JkRequestLogFormat   "%w %V %T %r %s"
> JkMount /jsp-examples/* ajp13
> JkMount /servletsp-examples/* ajp13
> JkMount /manager/* ajp13
> JkMount /ohpr/* ajp13
> JkMount /demo-b/* ajp13
> ....
>
> workers.properties:
>
> <<
> # Define 1 real worker using ajp13
> worker.list=ajp13
> # Set properties for worker1 (ajp13)
> worker.ajp13.type=ajp13
> worker.ajp13.host=localhost
> worker.ajp13.port=8009
> worker.ajp13.connection_pool_timeout=600
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@(protected)
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.