tomcat默认最大连接数与调整

一般来说我们都是用tomcat默认的配置做基础的本地开发,测试及生产肯定不用tomcat啦,正式一点的企业肯定换大型容器了,当然不排除还是用tomcat或者它的集群的,言归正传,tomcat的连接数相关配置及修改干货如下:

在tomcat配置文件server.xml中的标签配置中,和连接数相关的参数有下面几个(如果你现在看肯定都没有的):
minProcessors------------------最小空闲连接线程数,用于提高系统处理性能,默认值为10
maxProcessors-----------------最大连接线程数,即:并发处理的最大请求数,默认值为75
acceptCount---------------------允许的最大连接数,应大于等于maxProcessors,默认值为100
enableLookups-----------------是否反查域名,取值为:true或false。为了提高处理能力,应设置为false
connectionTimeout------------网络连接超时,单位:毫秒。设置为0表示永不超时,这样设置有隐患的。通常可设置为30000毫秒。

P.S.如果你要手动增加这些链接相关参数,那么根据以上参数肯定是找不到的,官方文档提示需要搞另外两个参数才能加大并发连接数,那就是maxProcessors和acceptCount。

官方原话及翻译:

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).

如果接收到的并发请求比当前可用的请求处理线程所能处理的更多,则将创建额外的线程到配置的最大值(maxThreads 属性)。

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).

如果接收到更多的并发请求,则它们被堆叠在由连接器创建的服务器套接字内,直到配置的最大值(acceptCount 属性)。

所以需要设置的是maxThreads和acceptCount这两个值,两者的默认值分别是200和100,要调整Tomcat的默认最大连接数,可以增加这两个属性的值,并且使acceptCount大于等于maxThreads:

 

你可能感兴趣的:(tomcat)