Tomcat 7最大并发连接数的正确修改方法
2015-05-29 17:20
633 查看
Tomcat 7最大并发连接数的正确修改方法
转载:http://blog.csdn.net/qysh123/article/details/11678903
这是个很简单的问题,但是搜了一圈,发现大家都写错了。所以这里总结一下:
几乎所有的中文网页都介绍,要修改Tomcat的默认最大并发连接数,应该进行如下设置(实际上这些步骤是错误的):
--------------------------------------------
在tomcat配置文件server.xml中的配置中,和连接数相关的参数有:
minProcessors:最小空闲连接线程数,用于提高系统处理性能,默认值为10
maxProcessors:最大连接线程数,即:并发处理的最大请求数,默认值为75
acceptCount:允许的最大连接数,应大于等于maxProcessors,默认值为100
enableLookups:是否反查域名,取值为:true或false。为了提高处理能力,应设置为false
connectionTimeout:网络连接超时,单位:毫秒。设置为0表示永不超时,这样设置有隐患的。通常可设置为30000毫秒。
其中和最大连接数相关的参数为maxProcessors和acceptCount。如果要加大并发连接数,应同时加大这两个参数。
web server允许的最大连接数还受制于操作系统的内核参数设置,通常Windows是2000个左右,Linux是1000个左右。Unix中如何设置这些参数,请参阅Unix常用监控和管理命令
具体的配置信息:
Java代码
--------------------------------------------
但是我仔细查了一圈,发现这个说法只是以讹传讹,并不适用于Tomcat 5.5以上的版本。这里先教大家怎么去查Tomcat的官网:
首先,在这里:http://tomcat.apache.org/ 我们点击左侧导航栏中“Documentation”下的Tomcat 7.0,进入到这个链接中:http://tomcat.apache.org/tomcat-7.0-doc/index.html ,详细的信息我们不用都看,在左侧导航栏中有一个链接Configuration,我们点进去之后,再点击其左侧导航栏中connector一项的HTTP,就进入到HTTP连接数及其他相关属性的设置页面了。在这里(http://tomcat.apache.org/tomcat-7.0-doc/config/http.html)我们可以看到,在Connector的属性配置中,压根就没有maxProcessors等的设置选项。其中这句话已经介绍得很清楚:
If more simultaneous requests are received than can be handled by the currently available request processing threads, additional threads will be created up to the configured maximum (the value of the maxThreads attribute). If still more simultaneous requests are received, they are stacked up inside the server socket created by the Connector, up to the configured maximum (the value of the acceptCount attribute).
所以我们需要设置的是maxThreads和acceptCount这两个值:
其中,maxThreads的介绍如下:
The maximum number of request processing threads to be created by this Connector, which therefore determines the maximum number of simultaneous requests that can be handled. If not specified, this attribute is set to 200. If an executor is associated with this connector, this attribute is ignored as the connector will execute tasks using the executor rather than an internal thread pool.
而acceptCount的介绍为:
The maximum queue length for incoming connection requests when all possible request processing threads are in use. Any requests received when the queue is full will be refused. The default value is 100.
所以两者的默认值分别是200和100,要调整Tomcat的默认最大连接数,可以增加这两个属性的值,并且使acceptCount大于等于maxThreads:
[html] view plaincopyprint?
Html代码 收藏代码
今天就记录这么多,希望大家以后在转载别人的经验时更用心些,不要老出现上面那些以讹传讹的情况。也希望能对有些朋友起到帮助。
转载:http://blog.csdn.net/qysh123/article/details/11678903
这是个很简单的问题,但是搜了一圈,发现大家都写错了。所以这里总结一下:
几乎所有的中文网页都介绍,要修改Tomcat的默认最大并发连接数,应该进行如下设置(实际上这些步骤是错误的):
--------------------------------------------
在tomcat配置文件server.xml中的配置中,和连接数相关的参数有:
minProcessors:最小空闲连接线程数,用于提高系统处理性能,默认值为10
maxProcessors:最大连接线程数,即:并发处理的最大请求数,默认值为75
acceptCount:允许的最大连接数,应大于等于maxProcessors,默认值为100
enableLookups:是否反查域名,取值为:true或false。为了提高处理能力,应设置为false
connectionTimeout:网络连接超时,单位:毫秒。设置为0表示永不超时,这样设置有隐患的。通常可设置为30000毫秒。
其中和最大连接数相关的参数为maxProcessors和acceptCount。如果要加大并发连接数,应同时加大这两个参数。
web server允许的最大连接数还受制于操作系统的内核参数设置,通常Windows是2000个左右,Linux是1000个左右。Unix中如何设置这些参数,请参阅Unix常用监控和管理命令
具体的配置信息:
Java代码
--------------------------------------------
但是我仔细查了一圈,发现这个说法只是以讹传讹,并不适用于Tomcat 5.5以上的版本。这里先教大家怎么去查Tomcat的官网:
首先,在这里:http://tomcat.apache.org/ 我们点击左侧导航栏中“Documentation”下的Tomcat 7.0,进入到这个链接中:http://tomcat.apache.org/tomcat-7.0-doc/index.html ,详细的信息我们不用都看,在左侧导航栏中有一个链接Configuration,我们点进去之后,再点击其左侧导航栏中connector一项的HTTP,就进入到HTTP连接数及其他相关属性的设置页面了。在这里(http://tomcat.apache.org/tomcat-7.0-doc/config/http.html)我们可以看到,在Connector的属性配置中,压根就没有maxProcessors等的设置选项。其中这句话已经介绍得很清楚:
If more simultaneous requests are received than can be handled by the currently available request processing threads, additional threads will be created up to the configured maximum (the value of the maxThreads attribute). If still more simultaneous requests are received, they are stacked up inside the server socket created by the Connector, up to the configured maximum (the value of the acceptCount attribute).
所以我们需要设置的是maxThreads和acceptCount这两个值:
其中,maxThreads的介绍如下:
The maximum number of request processing threads to be created by this Connector, which therefore determines the maximum number of simultaneous requests that can be handled. If not specified, this attribute is set to 200. If an executor is associated with this connector, this attribute is ignored as the connector will execute tasks using the executor rather than an internal thread pool.
而acceptCount的介绍为:
The maximum queue length for incoming connection requests when all possible request processing threads are in use. Any requests received when the queue is full will be refused. The default value is 100.
所以两者的默认值分别是200和100,要调整Tomcat的默认最大连接数,可以增加这两个属性的值,并且使acceptCount大于等于maxThreads:
[html] view plaincopyprint?
Html代码 收藏代码
今天就记录这么多,希望大家以后在转载别人的经验时更用心些,不要老出现上面那些以讹传讹的情况。也希望能对有些朋友起到帮助。
相关文章推荐
- Eclipse-maven项目发布到tomcat没有附带lib拷贝
- Tomcat的性能与最大并发(1000)
- 导入tomcat源码到eclipse中
- 初学Maven常见错误及解决方法
- TomCat 7.x 端口问题 以及 MySQL如何启动问题
- Tomcat版本与Servlet、JSP等版本的支持关系
- 解决Tomcat在服务器中能启动但访问不了的问题
- 总结:Apache/Tomcat/JBOSS/Jetty/Nginx区别
- Tomcat内存、连接数等性能参数设置
- tomcat版本号修改已dwr配置错误安全漏洞整改
- tomcat打印详细日志信息
- Tomcat源码阅读系列(四)Connector连接器
- nginx+tomcat负载均衡
- 安装IntelliJ IDEA热部署tomcat插件JreBel
- Tomcat服务器如何清理缓存
- tomcat 安装与配置
- 深入剖析Tomcat会话机制
- SOLR源码在Myeclipse/eclipse下搭建(并在tomcat下完美运行)
- 启动运行多tomcat
- java web 简析--二,TOMCAT结构及运行过程解析