Tomcat7以及以上版本设置最大连接数和内存
2017-12-01 11:29
561 查看
一、Tomcat 最大连接数设置:
Tomcat的官网介绍:
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?
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" acceptCount="500" maxThreads="400" />
Html代码
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" acceptCount="500" maxThreads="400" />
二、Tomcat7以及以上版本内存设置
Tomcat的启动分为startupo.bat启动和注册为windows服务的启动,下面一一说明。
1.startup.bat启动
在tomcat_home/bin目录下找到catalina.bat,用文本编辑器打开,加上下面一行:
set JAVA_OPTS= -Xms1024M -Xmx1024M -XX:PermSize=256M -XX:MaxNewSize=256M -XX:MaxPermSize=256M
解释一下各个参数:
-Xms1024M:初始化堆内存大小(注意,不加M的话单位是KB)
-Xmx1029M:最大堆内存大小
-XX:PermSize=256M:初始化类加载内存池大小
-XX:MaxPermSize=256M:最大类加载内存池大小
-XX:MaxNewSize=256M:这个还不清楚哈,有知道的说声
还有一个-server参数,是指启动jvm时以服务器方式启动,比客户端启动慢,但性能较好,大家可以自己选择。
2.windows服务启动
如果你的tomcat是注册为windows服务并且是以服务方式启动的,那么上面的方法就无效了,因为这时tomcat启动是读取注册表的参数,而不是读取批处理文件的参数,这时我们有两种方法来设置jvm参数。
第一种比较简单,tomcat为我们提供了一个设置启动参数的窗体,双击tomcat_home/bin目录下的tomcat6w.exe,如图
下方的Initial memory pool就是初始化堆内存大小,Maximun memory pool是最大堆内存大小。
而要设置Perm Gen池的大小就要在Java Option里面加参数了,在里面加上:
-Dcatalina.base=%tomcat_home%
-Dcatalina.home=%tomcat_home%
-Djava.endorsed.dirs=%tomcat_home%\endorsed
-Djava.io.tmpdir=%tomcat_home%\temp
-XX:PermSize=256M
-XX:MaxPermSize=256M
-XX:ReservedCodeCacheSize=48M
-Duser.timezone=GMT+08
(PS:网上说每一行后面不要有空格,没试过)
第二种方法是打开注册表->HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Procrun 2.0\Tomcat6\Parameters\Java(路径可能有一点点差别)
修改Options的值,把刚才上面那些参数加进去就OK了。(别忘了先备份一下注册表)
Tomcat的官网介绍:
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?
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" acceptCount="500" maxThreads="400" />
Html代码
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" acceptCount="500" maxThreads="400" />
二、Tomcat7以及以上版本内存设置
Tomcat的启动分为startupo.bat启动和注册为windows服务的启动,下面一一说明。
1.startup.bat启动
在tomcat_home/bin目录下找到catalina.bat,用文本编辑器打开,加上下面一行:
set JAVA_OPTS= -Xms1024M -Xmx1024M -XX:PermSize=256M -XX:MaxNewSize=256M -XX:MaxPermSize=256M
解释一下各个参数:
-Xms1024M:初始化堆内存大小(注意,不加M的话单位是KB)
-Xmx1029M:最大堆内存大小
-XX:PermSize=256M:初始化类加载内存池大小
-XX:MaxPermSize=256M:最大类加载内存池大小
-XX:MaxNewSize=256M:这个还不清楚哈,有知道的说声
还有一个-server参数,是指启动jvm时以服务器方式启动,比客户端启动慢,但性能较好,大家可以自己选择。
2.windows服务启动
如果你的tomcat是注册为windows服务并且是以服务方式启动的,那么上面的方法就无效了,因为这时tomcat启动是读取注册表的参数,而不是读取批处理文件的参数,这时我们有两种方法来设置jvm参数。
第一种比较简单,tomcat为我们提供了一个设置启动参数的窗体,双击tomcat_home/bin目录下的tomcat6w.exe,如图
下方的Initial memory pool就是初始化堆内存大小,Maximun memory pool是最大堆内存大小。
而要设置Perm Gen池的大小就要在Java Option里面加参数了,在里面加上:
-Dcatalina.base=%tomcat_home%
-Dcatalina.home=%tomcat_home%
-Djava.endorsed.dirs=%tomcat_home%\endorsed
-Djava.io.tmpdir=%tomcat_home%\temp
-XX:PermSize=256M
-XX:MaxPermSize=256M
-XX:ReservedCodeCacheSize=48M
-Duser.timezone=GMT+08
(PS:网上说每一行后面不要有空格,没试过)
第二种方法是打开注册表->HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Procrun 2.0\Tomcat6\Parameters\Java(路径可能有一点点差别)
修改Options的值,把刚才上面那些参数加进去就OK了。(别忘了先备份一下注册表)
相关文章推荐
- 如何更改tomcat7及以上版本内存设置
- java.lang.OutOfMemoryError: Java heap space 如何更改tomcat7及以上版本内存设置
- 如何更改tomcat7及以上版本内存设置
- 如何更改tomcat7及以上版本内存设置
- 如何更改tomcat7及以上版本内存设置
- linux下tomcat优化,设置最大连接数,内存,Jconsole监控
- 【工具设置】如何在Windows XP 的IIS中增加多个站点以及如何增大最大连接数。
- 设置tomcat5.5以上的jvm最大内存值
- JBOSS以及tomcat最大连接数配置和jvm内存配置
- 设置tomcat5.5以上的jvm最大内存值
- windows下MySQL5.6以上版本,如何通过修改配置文件来修改数据库的最大连接数啊?
- linux下tomcat设置最大连接数,设置最大内存
- Ubuntu 16.04下安装以太坊编译环境以及设置合约功能(支持geth 1.6以及solc 0.4.16版本以上)
- 将Oracle数据库操作模式改为共享服务器模式--调整ORACLE内存设置--修改Oracle最大连接数
- memcached 最大连接数及其内存大小的设置
- linux下tomcat设置最大连接数,设置最大内存
- linux下tomcat优化,设置最大连接数,内存,Jconsole监控
- linux下tomcat设置最大连接数,设置最大内存,使用jconsole监控
- memcached 最大连接数及其内存大小的设置
- memcached 最大连接数及其内存大小的设置