.Tomcat a stress test, and the parameters optimized by adjusting the configuration Tomcat
1. Deploy a web project, test access (need to install mysql and the JDK)
1.1.1 SQL script execution will generate the corresponding database
will be uploaded to the server SQL script, by cat dashboard.sql | mysql -uroot -p
1.1.2 Deployment Project
The items uploaded to a Linux system extract the Tomcat webapps folder directory
to find the item, jdbc.properties modify configuration files, according to the actual situation
Start Tomcat 1.1.3
Client access: http://192.168.42.123:8080/index
2.Jmeter stress test tool
after extraction is completed into the bin directory, double-click jmeter.bat start, you can start by next Opetions there Choose Lanauge choose Simplified Chinese
You can also modify white theme
2.1 Create a new thread group, the number of threads 1000, the number of cycles is 10
2.2 Click the thread group to create a new HTTP protocol sampler
using the http protocol, address linux address, port tomcat8080 port access address / index
2.3 Monitoring add request
2.4 Click Start test
3.Tomcat optimization
Without any configuration:
average request processing time: 61319
Error Error rate: 44.38%
Throughput: 12.8 / S
3.1 optimization program: Disable Service AJP
stop Tomcat: directory change to the bin by ./shutdown.sh
found decompression tomacat conf file directory folder, will be among the AJP service server.xml comments
bin directory to start: ./ startup.sh && tail -f ../logs/catalina.out
test results are as follows:
The average processing time of the request: 23900 + -
Error Error rate: 55% + -
throughput: 20 is / S + -
3.2 Optimization Scheme II: to move the actuator (thread pool)
Test a: up thread 500 '
The initial 50
The maximum number of wait queue 100
The run mode to nio2
Stop tomcat: Switch to the bin directory by ./shutdown.sh
find tomacat extract the directory under the conf folder, modify the server.xml
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="500" minSpareThreads="50" prestartminSpareThreads="true" maxQueueSize="100"/> <Connector executor="tomcatThreadPool" port="8080" protocol="org.apache.coyote.http11.Http11Nio2Protocol" connectionTimeout="20000" redirectPort="8443" />
bin directory Start: ./ startup.sh && tail -f ../logs/catalina.out
average request processing time: 4200
Error error rate: 9.30%
Throughput: 180 [/ S
4.Tomcat optimization: optimize the parameters of the JVM
4.1 enable parallel garbage collector
modify configuration files catalina.sh
JAVA_OPTS="-XX:+UseParallelGC -XX:+UseParallelOldGC -Xms64m -Xmx512m
-XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps
-XX:+PrintHeapAtGC -Xloggc:../logs/gc.log"
Use gceasy.io site log analysis
It concluded: the young generation memory allocation is too small. Entire heap memory allocation is too small
JAVA_OPTS="-XX:+UseParallelGC -XX:+UseParallelOldGC -Xms128m
-Xmx1024m -XX:NewSize=64m -XX:MaxNewSize=256m -XX:+PrintGCDetails
-XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC
-Xloggc:../logs/gc.log"
4.2 Enabling G1 garbage collector
JAVA_OPTS="-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -Xms128m
-Xmx1024m -XX:+PrintGCDetails -XX:+PrintGCTimeStamps
-XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -Xloggc:../logs/gc.log"
G1 highest efficiency
when 5.Tomcat optimization, to continue to test the configuration for the current environment
to sum up
Optimization points: 1.Tomcat Configuration
Tuning parameters 2.JVM