[tomcat调优]Tomcat7中maxThreads等于-1问题

原文链接:https://blog.csdn.net/weixin_38278878/article/details/80144397

[tomcat调优]Tomcat7中maxThreads等于-1问题

2018-04-29 17:54:55  阅读数 2083更多

分类专栏: 错误解决方案

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

本文链接:https://blog.csdn.net/weixin_38278878/article/details/80144397

今天给服务器上的Tomcat进行调优,配置如下:

<span style="color:#000000"><code><span style="color:#006666 !important"><<span style="color:#4f4f4f !important">Executor</span> <span style="color:#4f4f4f !important">name</span>=<span style="color:#009900 !important">"tomcatThreadPool"</span> <span style="color:#4f4f4f !important">namePrefix</span>=<span style="color:#009900 !important">"catalina-exec-"</span>
   <span style="color:#4f4f4f !important">maxThreads</span>=<span style="color:#009900 !important">"500"</span>  <span style="color:#4f4f4f !important">minSpareThreads</span>=<span style="color:#009900 !important">"5"</span>  /></span>


<span style="color:#006666 !important"><<span style="color:#4f4f4f !important">Connector</span> <span style="color:#4f4f4f !important">executor</span>=<span style="color:#009900 !important">"tomcatThreadPool"</span> <span style="color:#4f4f4f !important">port</span>=<span style="color:#009900 !important">"8080"</span>              
    <span style="color:#4f4f4f !important">protocol</span>=<span style="color:#009900 !important">"org.apache.coyote.http11.Http11NioProtocol"</span>
    <span style="color:#4f4f4f !important">connectionTimeout</span>=<span style="color:#009900 !important">"20000"</span> <span style="color:#4f4f4f !important">redirectPort</span>=<span style="color:#009900 !important">"8443"</span> /></span></code></span>

 

将线程池可以容纳的最大线程数设为500,最小不活跃线程数设为5

结果如下: 
[tomcat调优]Tomcat7中maxThreads等于-1问题

最小线程数设置成功,最大线程数为-1;之后将maxThreads改成了默认值200,1000等等,都是显示-1; 
难道这个属性失效了吗?

经过测试,这个属性是生效的,将其设为1后,Current thread count(当前线程数)是不会超过1的。

但为什么会显示-1呢? 查了tomcat7文档的maxThreads属性: 
[tomcat调优]Tomcat7中maxThreads等于-1问题

最后一句话“Note that if an executor is configured any value set for this attribute will be recorded correctly but it will be reported (e.g. via JMX) as -1 to make clear that it is not used.”就说到了这个情况,意思大概是: 
如果配置了一个Executor,则该属性的任何值集将被正确记录,但是它将被显示为-1

折腾了一个多小时,终于真相大白。

 

上一篇:Tomcat运行模式连接数和线程池


下一篇:Tomcat 调优的技巧