Tomcat tuning summary

Tomcat optimization:

1.
Tomcat memory optimization Tomcat generally has a default memory size, and its default value is very small for the entire physical memory. If tomcat memory is not configured, server resources will be greatly wasted, and verification affects the performance of the system. Memory configuration is particularly important for systems with a large number of users.

**Under the Windows platform, in the catalina.bat file in the bin directory,** find @echo off and add the following similar statement to the line below it.

SET CATALINA_OPTS= -Xms512m -Xmx512m -Xmn125m

Parameter description:
-server: must be used as the first parameter, performance is good when multiple CPUs
-Xms: java Heap initial size. The default is 1/64 of physical memory.
-Xmx: Maximum value of java heap. It is recommended to be set to half of the physical memory. Cannot exceed physical memory.
-Xmn: The heap size of the young generation. Generally one
- third or one - fourth of Xmx- XX:MetaspaceSize=128m initial metaspace size, the default is generally 21m.
-XX:MaxMetaspaceSize=256m Maximum metaspace size, no upper limit by default, determined by OS memory

Jps view tomcat process
Bootstrap is a tomcat process.
Jmap –heap 1184

Jmeter pressure test
memory 512m test result
10 seconds 3000
SET CATALINA_OPTS= -Xms512m -Xmx512m -Xmn125m
Insert picture description here
memory 2G test result
SET CATALINA_OPTS= -Xms2048m -Xmx2048m -Xmn500m
Insert picture description here
2. tomcat network optimization
Default:

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

6000 requests sent in 10 seconds are tested as follows

Insert picture description here
Optimization: Use nio

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

Send 6000 requests in 10 seconds to test as follows
Insert picture description here
3. Thread pool optimization
Adjust the maximum number of threads:

<Connector port="8080" 
	protocol="org.apache.coyote.http11.Http11Nio2Protocol" connectionTimeout="20000"
               redirectPort="8443" 
			   maxThreads="400" 
			   调maxThreads
			   />

Summary: The
Tomcat optimized configuration file directory is:
in the catalina.bat file in the bin directory under the Windows platform.
Tuning: memory, io, thread pool!

Guess you like

Origin blog.csdn.net/DoChengAoHan/article/details/103189083