tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Remy Maucherat <r...@apache.org>
Subject Re: Tomcat keepAliveTimeout
Date Fri, 29 Sep 2006 22:37:15 GMT
Filip Hanik - Dev Lists wrote:
> I like the trick, it's smart, but I believe we could also achieve it 
> with keep alive request limits, ie, when thread count gets high, turn 
> off keep alive by mocking maxKeepAliveRequests="1"
> ie, this way it doesn't affect the servlet and its usage of the stream.

It does it too.

         int keepAliveLeft = maxKeepAliveRequests;
         int soTimeout = socket.getSoTimeout();
         int oldSoTimeout = soTimeout;

         int threadRatio = (endpoint.getCurrentThreadsBusy() * 100)
                 / endpoint.getMaxThreads();
         if ((threadRatio > 33) && (threadRatio <= 66)) {
             soTimeout = soTimeout / 2;
         } else if ((threadRatio > 66) && (threadRatio <= 90)) {
             soTimeout = soTimeout / 3;
             keepAliveLeft = 1;
         } else if (threadRatio > 90) {
             soTimeout = soTimeout / 20;
             keepAliveLeft = 1;
         }

So:
- less than 33% of threads used: nothing
- less than 66%: timeout / 2
- less than 90%: no keepalive and timeout / 3
- more than 90%: no keepalive and really short timeout

Overall, I think the tricks may look cool on paper, but won't do 
anything particularly useful in practice. I removed all of them after a 
very short while in the APR connector.

I suppose some of it could be kept, and some could be removed (like the 
timeout tweaking; however, since timeout with java.io doesn't work on 
output, it won't do anything unless either a client messes with the 
sending of the request header or is too slow uploading its data).

Rémy

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


Mime
View raw message