Friday 12 January 2018

Jboss AJP thread pool not released idle threads


In this post, I am going to explain the problem and the solution related to AJP connector executor leaking threads.

We may notice and detect that AJP thread pool with the thread counts will start increase continuously on application servers.  It looks like that the idle threads never recycle or reclaim even after keepalive-time. This behavior will happen continuously even if the system will remain idle for a long period of time (without any user request). The application leak connections because it is not closing the AJP connection and returning them to the pool.


In the case of unbounded-queue-thread-pool executor configured and the default maximum-connections value being used, a new thread will create for every new request and will remain idle forever. As the number of AJP requests increase, the response from Jboss EAP may get slow eventually.

The reason for this behavior is that the AJP thread-pool connections by default have no timeout (default value of "DEFAULT_CONNECTION_TIMEOUT" is -1 for AJP, which means it never recycle) and therefore, the thread connection will persist permanently once established. The same behavior detectable if we use httpd/mod_cluster in front of the JBoss which will invoke periodic pings to JBoss and fill its connection pool.

The solution is to add the following System property in standalone.xml or domain.xml to limit the keepalive timeout value for AJP:

<property name="org.apache.coyote.ajp.DEFAULT_CONNECTION_TIMEOUT" value="600000" boot-time="true"/>


Here value 600000 menace 10 minutes . After 10 minutes of idle time, JBoss kills the thread.


However, if there are no strong reasons to use "DEFAULT_CONNECTION_TIMEOUT" option, keeping AJP connections open between apache and EAP is a good idea. The default value of "DEFAULT_CONNECTION_TIMEOUT" is -1 for AJP, which means it never disconnect.

No comments: