例如系统内存为4GB,可在Tomcat/bin/catalina.sh中加入如下配置:
JAVA_OPTS="-server
-Djava.awt.headless=true
-Xms2048m -Xmx2048m -Xss512k
-XX:NewSize=128m
-XX:MaxNewSize=512m
-XX:PermSize=128M
-XX:MaxPermSize=256M
-XX:+UseConcMarkSweepGC
-XX:+AggressiveOpts
-XX:+UseBiasedLocking
-XX:+DisableExplicitGC
-XX:MaxTenuringThreshold=10
-XX:+UseParNewGC
-XX:+CMSParallelRemarkEnabled
-XX:+UseCMSCompactAtFullCollection
-XX:LargePageSizeInBytes=128m
-XX:+UseFastAccessorMethods
-XX:+UseCMSInitiatingOccupancyOnly
-XX:+CMSIncrementalMode"
Tomcat/conf/server.xml 修改如下配置:
<Connector
port="8080"
protocol="HTTP/1.1"
URIEncoding="UTF-8"
minSpareThreads="25"
maxSpareThreads="75"
enableLookups="false"
disableUploadTimeout="true"
connectionTimeout="20000"
acceptCount="300"
maxThreads="300"
maxProcessors="1000"
minProcessors="5"
useURIValidationHack="false"
compression="on"
compressionMinSize="2048"
compressableMimeType="text/html,text/xml,text/JavaScript,text/css,text/plain,application/json"
redirectPort="8443"
/>