PDA

View Full Version : Resin 4.0.10 - thread-max not honoured in ThreadPool


snw
10-07-2010, 10:12 AM
I am posting here first rather than filing a bug report straight away in case this is user error.

Resin 4.0.10 looks like it doesn't action the thread-max element in config files. This is causing Resin to eventually run out of memory after spawning too many threads (my worst case scenario has each http request trigger a database call that takes about an 30 minutes to complete). My config file is this basic.conf:

<resin xmlns="http://caucho.com/ns/resin"
xmlns:resin="urn:java:com.caucho.resin">

<cluster-default>
<resin:import path="${__DIR__}/app-default.xml"/>
<server-default>
<thread-max>50</thread-max>
<thread-idle-min>10</thread-idle-min>
<thread-idle-max>20</thread-idle-max>
</server-default>
</cluster-default>

<cluster id="">
<server id="">
<thread-max>50</thread-max>
<thread-idle-min>10</thread-idle-min>
<thread-idle-max>20</thread-idle-max>
<http port="8080"/>
</server>

<host id="" root-directory=".">
<web-app id="/" root-directory="/tmp/test"/>
</host>
</cluster>
</resin>

So, pretty clear that max thread pool size should be 50 right? Or have I misunderstood the configuration options?

I have two test scripts in /tmp/test, status.jsp to print the number of threads in the pool / total threads allowed, and threads.jsp to change the thread pool max size programmatically.

status.jsp:
<H1> Thread Max: </H1>
<%=
com.caucho.env.thread.ThreadPool.getThreadPool().g etThreadCount()
%>/
<%=
com.caucho.env.thread.ThreadPool.getThreadPool().g etThreadMax()
%>

threads.jsp:
<H1> Thread Max: </H1>
<%
com.caucho.env.thread.ThreadPool.getThreadPool().s etThreadMax(128);
%>
<%=
com.caucho.env.thread.ThreadPool.getThreadPool().g etThreadCount()
%>/
<%=
com.caucho.env.thread.ThreadPool.getThreadPool().g etThreadMax()
%>

Running http://127.0.0.1:8080/status.jsp I get: Thread Max: 15/ 4096

Running http://127.0.0.1:8080/threads.jsp I get: Thread Max: 15/ 128

So, it started up with the wrong amount, but I was able to set it to a different amount later. The thread pool max directive in Resin 3.1.9 works fine for me. So - is this a bug in 4.0.10 and should I file it in the tracker, or is this a user error?

Thanks,

emil
10-07-2010, 11:04 PM
Hi,

It is indeed a bug. I've filed it here:

http://bugs.caucho.com/view.php?id=4251

Thanks for the in-depth description,
Emil

snw
10-08-2010, 07:02 AM
great, thank you

redsaki
12-01-2011, 10:18 PM
Bringing this thread back to life as I couldn't easily find a solution. I am attempting to use the thread-idle-min and thread-idle-max tags in my resin.xml file running Resin-Pro 4.0.24.

Doesn't look to work. I use VisualVM with a JMX connection to watch resin threadpool and the values are always 16 for min and 1024 for max. I got no clue where these values come from as the default is 5min/10max according to online docs.

If I yank the tags all the way out the values for thread-idle-min/max according to visualVM still report 16min/1024max.

Is it possible the bug fix is broken again or am I doing something wrong with config??

zwa
05-22-2013, 05:12 PM
I have the same problem with 4.0.32.

My setting is like this:


<server-default>
<jvm-arg-line>-Xmx2048m</jvm-arg-line>
<thread-max>64</thread-max>
</server-default>

<server id="" address="127.0.0.1" port="6800">

<-- More settings -->

<!-- Maximum number of threads. -->
<thread-max>20</thread-max>

</server>

Neither 64 or 20 is the number I got by calling com.caucho.util.ThreadPool.getThreadMax(); This function returns 128.

When I call this function
com.caucho.util.ThreadPool.setThreadMax(6);

Then the max becomes 6.