工作总结34 Tomcat7.0.79参数配置的问题

               最近在做部署的Tomcat7版本的性能优化,百度相关的资料后,配置的相关的参数后,后台显示警告信息,Tomcat启动的时候,报没有这几个属性。比如:minProcessors,maxProcessors,useURIValidationHack,都提示tomcat7没有这几个属性。但是这几个值在http://tomcat.apache.org/tomcat-7.0-doc/config/http.html 官方的说明中并不存在。
              网上的资料都是很老的版本,现在应该都是tomcat6.0或者7.0的了。很多老的配置已经过时了。比如minProcessors,maxProcessors这两个值网上大多资料说明修改他们俩,但是这两个值在最新官方的说明中并不存在。
             网上的都给出如下设置:

         minProcessors:最小空闲连接线程数,用于提高系统处理性能,默认值为10
         maxProcessors:最大连接线程数,即:并发处理的最大请求数,默认值为75
         acceptCount:允许的最大连接数,应大于等于maxProcessors,默认值为100
         enableLookups:是否反查域名,取值为:true或false。为了提高处理能力,应设置为false
         connectionTimeout:网络连接超时,单位:毫秒。设置为0表示永不超时,这样设置有隐患的。通常可设置为30000毫秒。
其中和最大连接数相关的参数为maxProcessors和acceptCount。如果要加大并发连接数,应同时加大这两个参数。

        在tomcat配置文件server.xml中的<Connector ... />配置中,和连接数相关的参数有: 
        对于tomcat7这个版本,minProcessors,maxProcessors并不存在了,官方对并发连接数给出如下解释:
        Each incoming request requires a thread for the duration of that request. 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 theConnector, up to the configured maximum (the
value of the acceptCount attribute). Any further simultaneous requests will receive "connection refused" errors, until resources are available to process them.
如果我们达到更多的并发请求,而这些请求不是我们当前的进程线可以处理得了的,那么额外的线程就会被重新配置以达到配置最大化(maxThreads属性所设定的值)。如果还有并发要求,那么他们就会被并入由连接器创建得服务器接口,从而达到配置最大化(直至达到acceptCount属性所设定的值)。
这个是tomcat官方的解释,在文中很清楚的说明了,修改最大连接数的办法。
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. 
处理request的最大线程数是由Connector决定的。这个值决定着目前可处理的最大并发数,如果没有设置,默认值为200,如果executor 与connector相关联,那么这个值将会被忽略,
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.
网上很多资料显示,linux的最大线程数是1000,window会高一点2000多。这个应该是根据机器cpu等的性能来计算的,实际的配置数据应该是根据自己的机器与负载情况多尝试找一个最优配置。

     maxThreads个线程处理不了的就在队列排队,最多acceptCount个排队,超出acceptCount的连接就会被拒绝。

     几个比较常用的配置参数如下:

maxThreads:tomcat起动的最大线程数,即同时处理的任务个数,默认值为200
acceptCount:当tomcat起动的线程数达到最大时,接受排队的请求个数,默认值为100
connectionTimeout:网络连接超时,单位:毫秒。设置为0表示永不超时,通常可设置为20000毫秒。
URIEncoding:指定Tomcat 容器的URL编码格式。
enableLookups:如果为true,则可以通过调用request.getRemoteHost()进行DNS查询来得到远程客户端的实际主机名,若为false则不进行DNS查询,而是返回其ip地址。建议设置false,能提高部分性能。
minSpareThreads:表示即使没有人使用也开这么多空线程等待
keepAliveTimeout:这个是保持长连接的时间限制,默认就是connectionTimeout 设置的时间。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值