Tomcat can increase stack memory and reasonably set concurrency to optimize:
1 Increase the Stack memory:
When the project is too large, it sometimes causes tomcat memory to overflow, to solve this problem can improve the Tomcat stack memory.
If you have used Tomcat, simply say "memory overflow". Typically, this problem occurs in the actual production environment. This problem is caused by the fact that Tomcat uses less memory for the process, by configuring the Tomcat configuration file
(Catalina.bat under Windows or catalina.sh under Linux) can solve this problem. This workaround is implemented by increasing the JVM's stack memory. That is, the JVM usually does not call the garbage collector, so the server can
Pay more attention to processing Web requests and ask to complete as soon as possible. To change the file (catalina.sh) located in "\tomcat Server folder\bin\catalina.sh", below, give the configuration information for this file:
Java_opts= "-DJAVA.AWT.HEADLESS=TRUE-DFILE.ENCODING=UTF-8-SERVER-XMS1024M-XMX1024M-XX:NEWSIZE=512M-XX: MAXNEWSIZE=512M-XX:PERMSIZE=512M-XX:MAXPERMSIZE=512M-XX:+DISABLEEXPLICITGC "
-xms– specifying the stack memory initialized
-xmx– specifying the maximum stack memory
These configuration changes will not be valid until you restart your Tomcat server.
2 Set the concurrency number reasonably:
In the Server.xml connector can be set MaxThreads Specify the number of concurrent,thevalue ofMaxThreads should be based on the size of the traffic, if the value is too low, there will not be enough threads to handle all the requests, The request goes into a wait state and is processed only when one of the processing threads is released, and if the setting is too large, Tomcat will take more time to start. So it depends on us setting a correct value for MaxThreads .
If you do not specify maxthreads default is 200, can be adjusted according to the actual number of concurrent increase, but more than 750, it is best to use the Tomcat cluster, such as 1000 concurrent, using two tomcat, each maxthread set to five;
<connector port= "8080" address= "localhost" 2maxthreads= "+" maxhttpheadersize= "8192" 3emptysessionpath= "true" Protocol= "http/1.1" 4enablelookups= "false" redirectport= "8181" acceptcount= "+" 5connectiontimeout= "20000" Disableuploadtimeout= "true"/>
Tomcat Performance Optimizations