My application uses JBoss 3.2.6 running Tomcat 5.5 on a 2.4 Debian Linux kernel. I have not specified the connectionTimeout attribute on the AJP connector between Apache and Tomcat - with the idea that the connections get reused between web requests. There is no KeepAlive persistent connections between the http client and the Apache webserver.
I notice that the number of Tomcat threads that are being used to KeepAlive the connections between Apache and Tomcat is much higher than the concurrent number of http requests coming into Apache. Since the number of requests coming into the webserver is fairly even and known up front, i was hoping to have a permanent connection between Apache and Tomcat without having to tear down the connection for every request coming into the Apache webserver. But over a period of time, almost all the Tomcat threads in the pool are in the KeepAlive state and Apache instead of reusing one of the existing threads, seems to ask for a new thread and is unable to find one, resulting in connection latency. Was wondering if this is expected behaviour and does applying a connectionTimeout to force unused connections between Apache and Tomcat make sense? Here is the stack showing the status of the Tomcat threads
"TP-Processor400" daemon prio=1 tid=0x08d430a0 nid=0x5c0 runnable [34bff000..34bff8d0] at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:129) at java.io.BufferedInputStream.fill(BufferedInputStream.java:183) at java.io.BufferedInputStream.read1(BufferedInputStream.java:222) at java.io.BufferedInputStream.read(BufferedInputStream.java:277) - locked <0x666cebf0> (a java.io.BufferedInputStream) at org.apache.jk.common.ChannelSocket.read(ChannelSocket.java:598) at org.apache.jk.common.ChannelSocket.receive(ChannelSocket.java:535) at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:663) at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:866) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683) at java.lang.Thread.run(Thread.java:534)