tomcat7 optimization


Tomcat7 optimization example:

1. Add the following parameters to the bin/catalina.bat file to optimize the JVM,
set JAVA_OPTS=
-server
-Xms1000M
-Xmx1000M #-Xms and -Xmx are set to the same value to avoid JVM due to frequent GC Causes performance to fluctuate
-Xss512k
-XX:+AggressiveOpts
-XX:+UseBiasedLocking
-XX:PermSize=64M
-XX:MaxPermSize=300M
-XX:+DisableExplicitGC
-XX:MaxTenuringThreshold=31
-XX:+UseConcMarkSweepGC
-XX:+UseParNewGC 
-XX :+CMSParallelRemarkEnabled
-XX:+UseCMSCompactAtFullCollection
-XX:LargePageSizeInBytes=128m 
-XX:+UseFastAccessorMethods
-XX:+UseCMSInitiatingOccupancyOnly
-Djava.awt.headless=true
The above configuration can basically achieve:
faster system response time
The JVM recycling speed is increased without affecting the response rate of the system. The
JVM memory is maximized and the
thread blocking situation is minimized.

-Xms is the memory allocated when the jvm is started, such as -Xms200m, which means the allocation of 200M
-Xmx is the maximum allocated during the jvm running process. Memory, such as -Xms500m, means that the jvm process can only occupy 500M of memory at most
-Xss The memory size allocated for each thread started by the jvm, the default is 1M in JDK1.5+


2. server.xml

<Connector port="8080" protocol ="HTTP/1.1"
           URIEncoding="UTF-8" 
           minSpareThreads="25"
           enableLookups="false"
           disableUploadTimeout="true"
           connectionTimeout="20000"
           acceptCount="300"  
           maxThreads="700"
           maxProcessors="1000"
           minProcessors= "5"
           useURIValidationHack="false"
           compression="on"
           compressionMinSize="2048"
           compressableMimeType="text/html,application/xml,application/json,application/javascript,text/css,text/plain" 
           redirectPort="8443"/>

minProcessors: Minimum idle connection thread Number, used to improve system processing performance, the default value is 10
maxProcessors: the maximum number of connection threads, that is: the maximum number of concurrent processing requests, the default value is 75
acceptCount: the maximum number of connections allowed, should be greater than or equal to maxProcessors, the default value is 100
enableLookups: Whether to reverse the domain name lookup, the value is: true or false. In order to improve processing power, it should be set to false
connectionTimeout: network connection timeout, unit: milliseconds. Setting it to 0 means that it will never time out, which is a hidden danger. Usually can be set to 30000 milliseconds.
The parameters related to the maximum number of connections are maxProcessors and acceptCount. If you want to increase the number of concurrent connections, you should increase these two parameters at the same time.
The maximum number of connections allowed by the web server is also subject to the kernel parameter settings of the operating system, usually about 2000 for Windows and about 1000 for Linux.

compression="on"

compressionMinSize1="2048"
Compression is performed when the minimum data size is exceeded
noCompressionUserAgents="gozilla, traviata"
Which clients send requests not to be compressed, the default is unlimited
compressableMimeType="text/html,text/xml,text/javascript,text/ css,text/plain"
Configure the data type to be compressed, the default is text/html,text/xml,text/plain

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326573538&siteId=291194637