tomcat性能优化

从网上找了相关的tomcat优化的相关文章,现整理如下,如有错误之处请指正:

    1、JAVA虚拟机性能优化

    2、在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常用监控和管理命令
tomcat4中的配置示例:
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8080" minProcessors="10" maxProcessors="1024"
enableLookups="false" redirectPort="8443"
acceptCount="1024" debug="0" connectionTimeout="30000" />
对于其他端口的侦听配置,以此类推。

    3、tomcat的nio配置(非阻塞式处理请求)

       将原来的tomcat中的server.xml中的

<Connector port="8080" protocol="HTTP/1.1"  connectionTimeout="20000"  redirectPort="8443" />

修改成

<Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"  connectionTimeout="20000"  redirectPort="8443" />

默认的处理方式使用的是org.apache.coyote.http11.Http11Protocol

    4、将conf/web.xml中的trimSpaces设为true,如果没有手动添加上,位置如下,(将响应的jsp页面中的空行或其他无用的字节去掉)

     <servlet>
        <servlet-name>jsp</servlet-name>
        <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
        <init-param>
            <param-name>fork</param-name>
            <param-value>false</param-value>
        </init-param>
        <init-param>
            <param-name>trimSpaces</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>xpoweredBy</param-name>
            <param-value>false</param-value>
        </init-param>
        <load-on-startup>3</load-on-startup>
    </servlet>

 

     在初始化参数中,还有development(默认为true,在进行项目产品部署时设置为false,不检查jsp修改);

genStrAsCharArray(默认为false,修改成true,  Should text strings be generated as chararrays, to improve performance in some cases? );

modificationTestInterval(默认为4,修改成true , Causes a JSP (and its dependent files) to not  be checked for modification during the specified time interval (in seconds) from the last time the JSP was checked for modification. A value of 0 will cause the JSP to be checked on every access.  Used in development mode only. [4]If development has to be set to true for any reason (such as dynamic generation of JSPs,如果项目中有地方动态形成jsp就不要把development改成false啦), setting this to a high value will improve performance a lot. (图省事就直接copy啦)

 

 5、 Jikes to compile JSP pages(没用过,只知道比sun的编译速度高点)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值