转自: http://blog.csdn.net/qysh123/article/details/11678903

这是个很简单的问题,但是搜了一圈,发现大家都写错了。所以这里总结一下:

几乎所有的中文网页都介绍,要修改Tomcat的默认最大并发连接数,应该进行如下设置(实际上这些步骤是错误的):

--------------------------------------------

在tomcat配置文件server.xml中的<Connector ... />配置中,和连接数相关的参数有:
  
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代码

  1. <Connector className="org.apache.coyote.tomcat4.CoyoteConnector" port="8080"
  2. minProcessors="5" maxProcessors="75" enableLookups="true" redirectPort="8443"
  3. acceptCount="100" debug="0" connectionTimeout="20000 " useURIValidationHack="false"
  4. protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>

--------------------------------------------

但是我仔细查了一圈,发现这个说法只是以讹传讹,并不适用于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:

  1. <Connector port="8080" protocol="HTTP/1.1"
  2. connectionTimeout="20000"
  3. redirectPort="8443" acceptCount="500" maxThreads="400" />

今天就记录这么多,希望大家以后在转载别人的经验时更用心些,不要老出现上面那些以讹传讹的情况。也希望能对有些朋友起到帮助。

tomcat 最大并发连接数设置的更多相关文章

  1. [Java] Tomcat环境变量设置

    @echo off title Tomcat环境变量设置 color 0a set /p inputTH=D:\Work\024_Tomcat if /i "%inputTH%"= ...

  2. Tomcat性能参数设置

    Tomcat性能参数设置 Tomcat性能参数设置 博客分类: Java LinuxTomcat网络应用多线程Socket 默认参数不适合生产环境使用,因此需要修改一些参数 1.修改启动时内存参数.并 ...

  3. Tomcat启动内存设置

    Tomcat启动内存设置 Tomcat的启动分为startupo.bat启动和注册为windows服务的启动,下面一一说明. 1.startup.bat启动 在tomcat_home/bin目录下找到 ...

  4. Tomcat服务时区设置

    tomcat服务不设置时间,会自动取系统时间,根据项目部署服务器位置不同时间会有差别,统一设置tomcat服务集群时间为东八区时间,具体设置如下: 在tomcat目录的bin文件夹下,找到文件cata ...

  5. 2018.4.1 Ubuntu16.04 下配置Tomcat服务器以及设置dingshi启动

    Tomcat自启动的设置技巧 以root用户登录系统: cd /etc/rc.d/init.d/ vi tomcat #!/bin/sh # # tomcat: Start/Stop/Restart ...

  6. tomcat内存大小设置

    tomcat内存大小设置 如果安装为windows服务,需要进行内存设置的时候,选择configure...界面, 在Java Tab页面内可以进行内存参数的设置. 学习了:http://elf884 ...

  7. Tomcat启动超时设置

    Tomcat启动超时设置: 处理方法: 1. 在server中找到当前Tomcat双击. 2.在视图中进行修改.(如下图:)

  8. MySQL连接处理方式及最佳并发连接数设置

    MySQL连接处理方式及最佳并发连接数设置 mysql是单进程,多线程的架构,通过创建多个线程来服务不同的用户连接,通常情况下,随着用户连接数的增加,mysql内部用于处理用户连接的线程也会同步的增长 ...

  9. tomcat的编码设置

    Connector port="8080" protocol="HTTP/1.1" URIEncoding="UTF-8"          ...

随机推荐

  1. eclipse安装activiti插件

    参考: https://blog.csdn.net/augustaurora/article/details/59618737 https://blog.csdn.net/qq_33547950/ar ...

  2. python - 流程控制基础习题

    #打印1 到100 的和** i = 0 s = 0 while i <100: i += 1 s += i print(s) print('1+2+,,100=',s) #打印字符A~Z fo ...

  3. html-头标签的使用

    HTML两部分组成 head和body ** 在head里面的标签就是头标签 ** title标签:表示在标签上显示的内容 ** meta标签:设置页面的一些相关内容(用的比较少) <meta ...

  4. error:0906D064:PEM routines:PEM_read_bio:bad base64 decode

    今天在使用easywechat对接企业打款到银行卡时,遇到了两个错误 error:0906D064:PEM routines:PEM_read_bio:bad base64 decode 和 erro ...

  5. 06.搭建kafka集群环境并测试

    参考: https://www.cnblogs.com/zhangs1986/p/6565639.html https://www.cnblogs.com/frankdeng/p/9403883.ht ...

  6. go字符串转换

    package main import ( "fmt" "strconv" ) /* 常用总结 1.str 转 int a, _ := strconv.Atoi ...

  7. linux-VM无法连接mks套接字连接尝试次数太多

    打开服务管理界面 将VM的服务都设为自动,并将其启动 在VM中重新打开虚拟机即可

  8. 20155215 《Java程序设计》实验二( Java面向对象程序设计)实验报告

    20155215 <Java程序设计>实验二( Java面向对象程序设计)实验报告 实验内容 初步掌握单元测试和TDD 理解并掌握面向对象三要素:封装.继承.多态 初步掌握UML建模 熟悉 ...

  9. 20155301 《Java程序设计》实验一(Java开发环境的熟悉)实验报告

    20155301 <Java程序设计>实验一(Java开发环境的熟悉)实验报告 一.实验内容及步骤 (一)使用JDK编译.运行简单的java程序 命令行下的程序开发 步骤:打开cmd,建立 ...

  10. echarts 柱状图移除圆角

    itemStyle: { normal: { color: '#59519f', barBorderColor: '#59519f', barBorderWidth: 6, barBorderRadi ...