本文优化信息,总体参考:tomcat性能调优
本机器环境:
linux
centos 6.5
tomcat7
jdk1.7
catalina.sh中注释最后一行添加
export JAVA_OPTS="-server -Xms1400M -Xmx1400M -Xss512k -XX:+AggressiveOpts -XX:+UseBiasedLocking -XX:PermSize=128M -XX:MaxPermSize=256M -XX:+DisableExplicitGC -XX:MaxTenuringThreshold=31 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -Djava.awt.headless=true "
server.xml 修改:
<Connector port="8084" protocol="HTTP/1.1"
URIEncoding="UTF-8" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true" connectionTimeout="20000"
acceptCount="1000" maxThreads="1000" maxProcessors="1000" minProcessors="5"
useURIValidationHack="false"
compression="on" compressionMinSize="2048"
compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain"
redirectPort="8443" />
<Connector executor="tomcatThreadPool"
port="8084" protocol="HTTP/1.1"
minProcessors="5"
maxProcessors="2000"
acceptCount="2000"
connectionTimeout="20000"
redirectPort="8443" />
模拟2000用户读取文件:
loadrunner负载压力测试如下图: