1.Tomcat optimized configuration
(1) Change the catalina.bat of Tomcat
Turn Java into server mode, increase the JVM's memory, add at the beginning of the file
setjava_opts=-server-xms1024m-xmx2048m-xss512k-xx:permsize=128m-xx:maxpermsize=256m
setcatalina_opts=-server-xms512m-xmx512m
Such as:
Xms: Initial Memory
XMX: Max Memory
(3) Change the server.xml of Tomcat
The following configuration is added in the <service name= "Catalina" > (2000 concurrency is not a problem in the pro test for 10 seconds).
<executorname= "Tomcatthreadpool" nameprefix= "catalina-exec-"
maxthreads= "minsparethreads=" maxidletime= "60000"/>
<connectorexecutor= "Tomcatthreadpool"
Port= "protocol=" http/1.1 "
Connectiontimeout= "60000"
keepalivetimeout= "15"
maxkeepaliverequests= "200"
Disableuploadtimeout= "false"
Enablelookups= "false"
redirectport= "8443"/>
Note that the number of maxthreads should not be adjusted too large, it is easy to produce the following error:
2,mysql optimized configuration
(1) Change MySQL my.ini (Windows) or MY.CNF (Linux)
max_connections=12000//maximum number of connections generally between 0~15000, try not to exceed 15000
max_user_connections=0//maximum number of user connections, 0 is not limited
interactive_timeout=31536000//time-out, set to one year, avoid connection pool errors
wait_timeout=31536000
QUERY_CACHE_SIZE=512M//query cache, try to set a larger, avoid errors
key_buffer_size=1024m
Query_cache_type= 1
max_allowed_packet=600m
Tomcat + MySQL high concurrency configuration optimization