tomcat performance tuning

 

1.----------------------Modify the memory size of TomcatJVM under Linux-------------------- --

To be added in catalina.sh under the bin of tomcat, before the location cygwin=false. Note that the quotation marks should be put on, and the red ones are newly added.

# OS specific support.  $var _must_ be set to either true or false.
JAVA_OPTS="-Xms256m -Xmx512m -Xss1024K -XX:PermSize=128m -XX:MaxPermSize=256m"
 cygwin=false

 

2 ---------------------- Modify Tomcat JVM memory size under windows-------------------- --

Case 1: The decompressed version of Tomcat needs to be started through startup.bat to load the configuration

To be added in catalina.bat under the bin of tomcat

rem Guess CATALINA_HOME if not defined
 set CURRENT_DIR=%cd% is added later, and the red ones are newly added.

set JAVA_OPTS=-Xms256m -Xmx512m -XX:PermSize=128M -XX:MaxNewSize=256m -XX:MaxPermSize=256m -Djava.awt.headless=true


rem Guess CATALINA_HOME if not defined
set "CURRENT_DIR=%cd%"
rem gjp add
set JAVA_OPTS=-server -Xms256m -Xmx512m -XX:PermSize=64M -XX:MaxNewSize=256m -XX:MaxPermSize=128m -Djava.awt.headless=true

 


3. Use a thread pool

   <!--The connectors can use a shared executor, you can define one or more named thread pools-->
     <!-- open pools -->
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
        maxThreads="800" minSpareThreads="50"
      />
     
     
        <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080
  
    <Connector port="8081"protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
 -->

    <!-- A "Connector" using the shared thread pool-->
    <!-- open pools -->
    <Connector executor="tomcatThreadPool"
               port="8081" protocol="org.apache.coyote.http11.Http11Protocol"
               connectionTimeout="20000"
               maxSpareThreads="750"
       acceptCount="800"
               redirectPort="8443" />
              
   
   
              
              
Description
       maxThreads="600" ///Maximum number of threads
       minSpareThreads="100"///Number of threads created during initialization
       maxSpareThreads= "500"///Once the number of threads created exceeds this value, Tomcat will close socket threads that are no longer needed.
       acceptCount="700"//Specify the number of requests that can be placed in the processing queue when all available threads for processing requests are used, and requests that exceed this number will not be processed

      There are too many maxthreads, resulting in too many switching and serious performance degradation. This number should be the carrying capacity of your single machine, the result obtained under the stress test.
       It cannot be increased arbitrarily. Under normal circumstances, 256-512 are already very high numerical
       references .csdn.net/peijunlin/archive/2009/06/05/4244401.aspx 3.Tomcat6 Some tuning settings for memory and connections.http://mcncc.com/simple/?t25909.html 4.Java virtual machine parameters -XX and other related parameters application. http://hi.baidu.com/charlesyy/blog/item/b89b5dee30cfdaf9b2fb95d5.html/cmtid/dda586260800bf1a8b82a173



 

Warning: [SetAllPropertiesRule]{Server/Service/Connector} Setting property 'maxSpareTheads' to '300' did not find a matching property.
But accessing the app works fine.
 Through online search, the specific solution is as follows:
The part of the Connector code that configures HTTPS in server.xml
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
                maxThreads="150" scheme="https" secure="true"
                clientAuth="false" sslProtocol="TLS"
                keystoreFile="your .keystore file" /> Change
the protocol parameter from "HTTP/1.1" to "org.apache.coyote.http11.Http11Protocol", re- Start Tomcat and you're done!
 According to Tomcat's official documentation http://tomcat.apache.org/tomcat-6.0-doc/config/http.html , "HTTP/1.1" and "

 

 

 

 

 

 

4. Open the monitoring page and view the parameter configuration

tomcat-users.xml

添加:<role rolename="manager-gui"/>

 

<user username="admin" password="admin123456" roles="manager-gui"/>

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326973793&siteId=291194637