tomcat 最大并发连接数设置
转自: 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代码
- <Connector className="org.apache.coyote.tomcat4.CoyoteConnector" port="8080"
- minProcessors="5" maxProcessors="75" enableLookups="true" redirectPort="8443"
- acceptCount="100" debug="0" connectionTimeout="20000 " useURIValidationHack="false"
- 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:
- <Connector port="8080" protocol="HTTP/1.1"
- connectionTimeout="20000"
- redirectPort="8443" acceptCount="500" maxThreads="400" />
今天就记录这么多,希望大家以后在转载别人的经验时更用心些,不要老出现上面那些以讹传讹的情况。也希望能对有些朋友起到帮助。
tomcat 最大并发连接数设置的更多相关文章
- [Java] Tomcat环境变量设置
@echo off title Tomcat环境变量设置 color 0a set /p inputTH=D:\Work\024_Tomcat if /i "%inputTH%"= ...
- Tomcat性能参数设置
Tomcat性能参数设置 Tomcat性能参数设置 博客分类: Java LinuxTomcat网络应用多线程Socket 默认参数不适合生产环境使用,因此需要修改一些参数 1.修改启动时内存参数.并 ...
- Tomcat启动内存设置
Tomcat启动内存设置 Tomcat的启动分为startupo.bat启动和注册为windows服务的启动,下面一一说明. 1.startup.bat启动 在tomcat_home/bin目录下找到 ...
- Tomcat服务时区设置
tomcat服务不设置时间,会自动取系统时间,根据项目部署服务器位置不同时间会有差别,统一设置tomcat服务集群时间为东八区时间,具体设置如下: 在tomcat目录的bin文件夹下,找到文件cata ...
- 2018.4.1 Ubuntu16.04 下配置Tomcat服务器以及设置dingshi启动
Tomcat自启动的设置技巧 以root用户登录系统: cd /etc/rc.d/init.d/ vi tomcat #!/bin/sh # # tomcat: Start/Stop/Restart ...
- tomcat内存大小设置
tomcat内存大小设置 如果安装为windows服务,需要进行内存设置的时候,选择configure...界面, 在Java Tab页面内可以进行内存参数的设置. 学习了:http://elf884 ...
- Tomcat启动超时设置
Tomcat启动超时设置: 处理方法: 1. 在server中找到当前Tomcat双击. 2.在视图中进行修改.(如下图:)
- MySQL连接处理方式及最佳并发连接数设置
MySQL连接处理方式及最佳并发连接数设置 mysql是单进程,多线程的架构,通过创建多个线程来服务不同的用户连接,通常情况下,随着用户连接数的增加,mysql内部用于处理用户连接的线程也会同步的增长 ...
- tomcat的编码设置
Connector port="8080" protocol="HTTP/1.1" URIEncoding="UTF-8" ...
随机推荐
- Linux-- 查看文件 more与其它
more 翻页查看 用法:more 文件名 nl 显示行号打印(不常用) 1.不打印空白行行号:nl -b t 文件名 类似 cat -b 文件名 2.打印所有行行号:nl -b a 文件名 类似 c ...
- Hadoop(12)-MapReduce框架原理-Hadoop序列化和源码追踪
1.什么是序列化 2.为什么要序列化 3.为什么不用Java的序列化 4.自定义bean对象实现序列化接口(Writable) 在企业开发中往往常用的基本序列化类型不能满足所有需求,比如在Hadoop ...
- 嵌入式Linux系统移植——uboot常用命令
flash的一般分区: 其它数据 环境变量 可执行程序.如bootloader print(可缩写为:pri):打印查看uboot这个软件中集成的环境变量setenv.saveenv:设置.保存环境变 ...
- C语言实现选择排序算法
新人新气象,我又来了,C语言实现选择排序.很基础的东西,原理什么的就不扯了. #include <stdio.h> #include <stdlib.h> #include & ...
- node.js之express中app.use
express中app.use 用法: app.use([path,] function [, function…]) 一.app.use() 在express中是怎么工作的 app.use在expr ...
- SDR软件无线电知识要点(一)噪声系数与噪声因子
SDR软件无线电知识要点(一)噪声系数与噪声因子 信号质量如何评估 Noise Figure (NF) or sensitivity and Error Vector Magnitude (EVM) ...
- nodejs搭建web服务器初级
nodejs搭建简单的web服务器 1.1简介 Node.js是基于Chrome JavaScript运行时建立的一个平台,实际上它是对Google Chrome V8引擎进行了封装,它主要用于创建快 ...
- flex tooltip css
<?xml version="1.0"?> <!-- tooltips/ToolTipStyleManager.mxml --> <mx:Applic ...
- 20155216 2016-2017-2 《Java程序设计》第二周学习总结
教材学习内容总结 类型 short占2字节 int占4字节 long占8字节 byte占1字节,可表示-128~127的整数 char占2字节 boolean不考虑占字节 float占4字节 doub ...
- 20155301 2016-2017-2 《Java程序设计》第2周学习总结
20155301 2016-2017-2 <Java程序设计>第2周学习总结 教材学习内容总结 教材的第三章内容主要分为两大方面: 一.程序中的数据类型,变量和运算符,主要讲述了各种类型的 ...