tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier>
Subject Re: mod_jk fails to forward request on high traffic
Date Tue, 08 Sep 2009 18:56:33 GMT
Rainer Jung wrote:
> On 08.09.2009 17:49, Mark Thomas wrote:
>> John Cherouvim wrote:
>>> Hello
>>> I have a website which during peak time (peak lasts around ~4 hours with
>>> 14 pageviews/sec, 140 http requests/sec) starts to drop pageview requests.
>> My guess is that all of your Tomcat AJP threads are tied up with idle
>> httpd threads.
>> Try the following in your httpd.conf:
>> JkOptions     +DisableReuse
> ... or read about the necessary timeouts on
Or start a lot more threads on that AJP Connector, since you have a lot 
of spare everything on that machine.
And if these are a lot of small requests by many separate clients, you 
may want to reduce your Apache KeepAliveTimeout to 4, then 3,..

The idea is :
- a browser connects to Apache and issues a request
- Apache is passing this request to one free Apache child
- this child sees that the request is for mod_jk (and, in the 
background, Tomcat)
- so one instance of an Apache child and mod_jk is now busy
- mod_jk connects to Tomcat
- to handle the request, the Tomcat Connector allocates one Tomcat 
thread (possibly starting a new one)
- the thread works and returns the response to mod_jk
- mod_jk returns the response to the Apache child
- the Apache child returns the response to the browser


since the connection is "keep-alive", if the same browser does not, on 
the same connection, issue any more requests, then the Apache child 
anyway waits on that connection for the duration of the 
KeepAliveTimeout.  Only when the timeout expires without new request, 
does the child close the connection and return itself to the available 
child pool.
So if the request takes 100 milliseconds to fulfill, and your 
KeepAliveTimeout is 5000 milliseconds, your Apache children sit there 
doing nothing (and being unavailable for other browsers requests) for :
(5000 ms + 100 ms) =  5100 ms = total time
of which
100 ms = time to actually fulfill request
100 ms / 5100 ms = 0.0196.. = 1.9 % "productive"
100 - 1.96 = 98.04 % "unproductive"
during which time they probably hold on to their mod_jk connection to 
Tomcat also, and thus there is also a Tomcat thread waiting, and doing 
nothing for the same unproductive time, and not being available for 
other clients and requests.

This is a horror scenario and, probably, in reality things are not so 
bad, depending on how your pages are and how smart all these little 
Apache/mod_jk/Tomcat pieces are.
But maybe worth thinking about anyway ?

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message