Configuration and optimization TOMCAT 8.5 JVM configuration (windows server)

Download the official tomcat, I used here is TOMCAT 8.5.46, then extract them, unpacked directory as shown below

A, server.xml configuration optimization

Enter the conf directory, open the server.xml file

 1. Locate <Executor name = "tomcatThreadPool" ... />, which will be modified as follows

<Executor name="tomcatThreadPool" 
namePrefix="catalina-exec-" 
maxThreads="500" 
minSpareThreads="80"
maxQueueSize="100" 
maxIdleTime="60000"
prestartminSpareThreads="true" />

 

 

maxThreads: The maximum number of concurrent, 200 default settings is generally recommended 500 to 800, depending on the hardware facilities and operations to determine
minSpareThreads: the number of threads created when initializing Tomcat, the default settings 25

maxQueueSize: maximum number of queue, exceeds the request is rejected

maxIdleTime: if the current thread is greater than the thread initialization, idle threads that the survival time, in milliseconds, default = 60,000 = 1 minute 60 seconds.
prestartminSpareThreads: When Tomcat initialization parameter values minSpareThreads initialized if a value is not equal to true, lacks effects on the minSpareThreads


2. Find <Connector port = "8080" ... />, which will be modified as follows

<Connector executor="tomcatThreadPool" port="80" 
redirectPort="8443"
protocol="org.apache.coyote.http11.Http11Nio2Protocol"
connectionTimeout="20000" 
maxConnections="10000" 
enableLookups="false" 
acceptCount="100" 
maxPostSize="10485760" 
maxHttpHeaderSize="65536" 
compression="on" 
disableUploadTimeout="true" 
compressionMinSize="2048"
acceptorThreadCount="2" 
processorCache="20000" 
tcpNoDelay="true" 
connectionLinger="5" 
URIEncoding="utf-8" 
server="Server Version 11.0"
compressableMimeType="text/html,text/xml,text/plain,text/css,text/javascript,application/javascript" />

protocol: TOMCAT8 used above org.apache.coyote.http11.Http11Nio2Protocol, more efficient, if the start is an error, please use org.apache.coyote.http11.Http11NioProtocol. There may be a change of port 8005,8009 lead.

connectionTimeout: Connector receiving time (milliseconds) after waiting for a connection, the default value is 60,000.
maxConnections: This value represents a maximum number of socket connections to the tomcat
enableLookups: Disable DNS query
acceptCount: tomcat start when the number of threads when the maximum number of accepted requests queued, the default value is 100.
maxPostSize: URL argument resolved by the container maximum length, 1 (less than 0) to disable this property, the default is 2097152 (2M) Note, FailedRequestFilter filter can be used to reject the request reached the limit.
maxHttpHeaderSize: http request header maximum extent, part of this length exceeds disregarded. General 8K.
compression: whether to enable GZIP compression on is enabled (text data compression) off is not enabled, force compresses all data
disableUploadTimeout: This flag allows the servlet container to use a different, usually longer upload data connection timeout. If not specified, this property is set to true, it disables the timeout.
compressionMinSize: only when the data size exceeds the minimum compressed
acceptorThreadCount: number of threads to accept connections. Increasing this value on multi-CPU machines, although you never really need more than two. There are also many non maintain the connection, you may want to increase this value. The default value is 1.
processorCache: protocol handler object processor cache to improve performance. This setting determines how much cache these objects. -1 means unlimited, the default is 200. If you do not use the Servlet 3.0 asynchronous processing, the default is to use the same maxThreads settings. If you are using Servlet 3.0 asynchronous processing, the default is the maximum number (synchronous and asynchronous) and the expected large maxThreads concurrent requests.
tcpNoDelay: If set to true, TCP_NO_DELAY options will be set at the server socket, and improve performance in most cases. This is the default setting is true.
connectionLinger: seconds off the socket connector when the continuous use. The default value is -1, the delay time disabling socket.
URIEncoding: website generally use UTF-8 as the default encoding.
server: hide Tomcat version information, hiding first version information in the HTTP header
compressableMimeType: Configuration Data Type want to compact

Second, the configuration file logging.properties

   Enter the conf directory, open the file logging.properties, all encoding = UTF-8 front line with '#' comment out this line, or when you run tomcat, console the Chinese all garbled, can also UTF-8 into GBK.

Third, configure the JVM

     Into the bin directory, create a file setevn.bat, then with Notepad, enter the following configuration information

       

SET JAVA_HOME=D:\Java\jdk1.8.0_221\jre

SET JAVA_OPTS=-server -Xms4096m -Xmx4096m -Xmn2048m -XX:PermSize=256m -XX:MaxPermSize=512m -XX:SurvivorRatio=10 -XX:MaxTenuringThreshold=12 -Xloggc:../logs/gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+DisableExplicitGC

 

 -server: Indicates that this is applied to the configuration of the server, special handling will be inside the JVM 
 -Xms4096m: minimum memory is provided JVM 2048m. This value can be set the same -Xmx, each JVM to avoid reallocate memory garbage collection completes.
 -Xmx4096m: Set JVM maximum memory available to 2048MB

 -Xmn2048m: New Generation Set size JVM (JDK1.4 later versions, this setting is equivalent to -XX: NewSize and -XX: MaxNewSize). General -Xmn size is about 1/2 of -Xms Do not set too large or too small, too large old's smaller, frequent Full GC, too small to minor GC frequent. If not set -Xmn, may be employed -XX: NewRatio = 2 is set, the same effect is
 -XX: NewSize: New Generation Set Size
 -XX: MaxNewSize: set the maximum size of the new generation

 -XX: PermSize: Permanent Set Generation size
 -XX: MaxPermSize: Generation permanently set the maximum size
 -XX: SurvivorRatio: young generation, from (Survivor1), to ( Survivor2) ratio Eden, if -XX: SurvivorRatio = 10 Since from, to equal memory size, from, to accounting for 1/12 of Young Generation space, Eden accounting 10/12;
 
 -XX: = NewRatio. 4: set the young generation (including Eden and two Survivor areas) and in old generation ratio (permanent removal generation). Is set to 4, the share of the young generation and old generation ratio of 1: 4, the young generation 1/5 of the entire stack; and in the case Xms = Xmx Xmn set, which parameter settings are not necessary.

 -XX: MaxTenuringThreshold = 10: Setting the maximum age of garbage, the default is: 15. If set to 0, then the younger generation of the object without Survivor areas, directly into the old generation. For more of the old generation of applications that can improve efficiency. If this value is set to a large value, then the young generation objects will be copied many times in Survivor areas, which can increase the object and then the young generation of survival time, an increase in the introduction to the young generation namely recycling. Note that, set -XX: MaxTenuringThreshold, does not represent the object must survive 10 times in the young generation was only promoted into the old era, it is only a maximum, in fact, there is a dynamic computer system to calculate each Jin into the threshold of old age, and a smaller MaxTenuringThreshold thresholding prevail.

 -Xloggc: ../ logs / gc.log GC log file location

-XX: + DisableExplicitGC: This will ignore the code manually calling GC makes System.gc () calls will become a air conditioning, will not trigger any GC
 Note: The above -Xms -Xmx -Xmn is in accordance with the 8G server memory configuration, the actual configuration, users need their own debugging

Determine whether the configuration works, go to the bin folder, open a command line window, enter catalina.bat configtest, which represents the configuration page appears as follows success

Guess you like

Origin www.cnblogs.com/zhuiyue82/p/11652842.html