Tomcat6线程池(Executor Thread pool)的配置

[quote]第一步,打开共享的线程池 [/quote]
 <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"/>

默认前后是注释<!-- -->掉的,去掉就可以了。其中

[b]name [/b]
The name used to reference this pool in other places in server.xml. The name is required and must be unique.
这个是线程池的名字,必须唯一,我们在后面的配置里要用到这个东西

[b]namePrefix [/b]
(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

[b]maxThreads [/b]
(int) The max number of active threads in this pool, default is 200
允许的最大线程池里的线程数量,默认是200,大的并发应该设置的高一些,反正只是限制而已,不占用资源

[b]minSpareThreads [/b]
(int) The minimum number of threads always kept alive, default is 25
最小的保持活跃的线程数量,默认是25.这个要根据负载情况自行调整了。太小了就影响反应速度,太大了白白占用资源。

[b]maxIdleTime [/b]
(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分钟。

[b]threadPriority [/b]
(int) The thread priority for threads in the executor, the default is Thread.NORM_PRIORITY
线程的等级。默认是Thread.NORM_PRIORITY


[quote]第二步[/quote]
在 Connector里指定使用共享线程池
 <Connector
port="8009"
protocol="AJP/1.3"
maxThreads="5000"
executor="tomcatThreadPool"

[b]注意,一旦使用了线程池,则其它的线程属性,比如 maxThreads等将被忽略[/b]


我测试了一下,由于每次请求不再需要重新分配线程,系统响应速度还是有很明显的改善的。

[quote]转:http://blog.youkuaiyun.com/java2000_net/article/details/3280020[/quote]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值