首先在你的TOMCAT的目录下%TOMCAT_HOME%\conf找到server.xml文件
第一步,打开共享的线程池
配置如下信息:
<Service name="Catalina">
<!--The connectors can use a shared executor, you can define one or more named thread pools-->
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="1000" minSpareThreads="50" maxIdleTime="600000"/>
name
The name used to reference this pool in other places in server.xml. The name is required and must be unique.
这个是线程池的名字,必须唯一,我们在后面的配置里要用到这个东西
namePrefix
(String) The name prefix for each thread created by the executor. The thread name for an individual thread will be namePrefix+threadNumber
线程的名字前缀,用来标记线程名字的,这样每个线程就用这个前缀加上线程编号了,比如
catalina-exec-1
catalina-exec-2
maxThreads
(int) The max number of active threads in this pool, default is 200
允许的最大线程池里的线程数量,默认是200,大的并发应该设置的高一些,反正只是限制而已,不占用资源
minSpareThreads
(int) The minimum number of threads always kept alive, default is 25
最小的保持活跃的线程数量,默认是25.这个要根据负载情况自行调整了。太小了就影响反应速度,太大了白白占用资源。
maxIdleTime
(int) The number of milliseconds before an idle thread shutsdown, unless the number of active threads are less or equal to minSpareThreads. Default value is 60000(1 minute)
超过最小活跃线程数量的线程,如果空闲时间超过这个设置后,会被关别。默认是1分钟。
threadPriority
(int) The thread priority for threads in the executor, the default is Thread.NORM_PRIORITY
线程的等级。默认是Thread.NORM_PRIORITY
第二步,在 Connector里指定使用共享线程池
源码
<Connector
port="8009"
protocol="AJP/1.3"
maxThreads="5000"
executor="tomcatThreadPool"
注意,一旦使用了线程池,则其它的线程属性,比如 maxThreads等将被忽略
我测试了一下,由于每次请求不再需要重新分配线程,系统响应速度还是有很明显的改善的。
分享到:
相关推荐
详细讲解了Tomcat6.0共享线程池配置和性能调优的方法
Tomcat是使用最广的Java Web容器,功能强大,可扩展性强
TOMCAT的线程池源码封装,有想学习TOMCAT的线程池源,或者觉得JDK的线程池源码效率不高,可以下载此代码
下面小编就为大家带来一篇基于tomcat的连接数与线程池详解。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
jsp配置+sql配置+tomcat配置jsp配置+sql配置+tomcat配置jsp配置+sql配置+tomcat配置jsp配置+sql配置+tomcat配置jsp配置+sql配置+tomcat配置jsp配置+sql配置+tomcat配置jsp配置+sql配置+tomcat配置jsp配置+sql配置+...
apache-tomcat-8.5配置优化后,配置好了,tomcat用户名密码,可直接使用admin
tomcat jdk 和tomat的一些配置文件包括server.xml和linux使用service启动tomcat
Tomcat配置方法 Tomcat配置方法 Tomcat配置方法
tomcat6.0配置(含配置视频下载 tomcat6.0配置(含配置视频下载 tomcat6.0配置(含配置视频下载 tomcat6.0配置(含配置视频下载
鉴于现在myeclipse10默认配置不上tomcat 8 问题,需要启动运行配置,参看文档。关于tomcat8配置,主要介绍关于tomcat8的配置文档。
Tomcat5.5配置SSL Tomcat5.5配置SSL Tomcat5.5配置SSL Tomcat5.5配置SSL
tomcat安装配置详解,tomcat安装配置详解,tomcat安装配置详解
tomcat优化配置tomcat优化配置tomcat优化配置tomcat优化配置
Tomcat服务器配置及数据库连接池配置(个人整理版)。纯粹个人整理意见。
centos上安装配置Tomcat环境,纯手工编写,测试过文档无误
Tomcat下redias配置: 1. context.xml 中的加入 <Valve className="com.orangefunction.tomcat6.redissessions.RedisSessionHandlerValve"/> <Manager className="com.orangefunction.tomcat6.redissessions....
Tomcat详解配置Tomcat详解配置Tomcat详解配置
tomcat配置tomcat配置tomcat配置tomcat配置tomcat配置tomcat配置tomcat配置
tomcat下配置https环境 tomcat下配置https环境 tomcat下配置https环境,亲测,可用。https://127.0.0.1:8443/
详细介绍在tomcat中配置数据源原理