November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Tomcat commonly used in the tuning

Tomcat commonly used in the tuning

In the usual use of Apache, Nginx or other related to the provision of Web services software has a corresponding performance module tuning changes, and in Tomcat also has a corresponding performance tuning modified configuration, here is simply to say more commonly used Several Tomcat in the performance tuning configuration parameters in the Tomcat tuning parameters can be divided into two parts: 1, in the Tomcat binary folder bin directory catalina.sh or catalina.bat add modify configuration tomcat Use the operating parameters; 2, in the Tom folder conf folder configuration changes server.xml in the container.

One, tomcat use the operating parameters catalina.sh tuning

Modify the catalina.sh script, add the modified JAVA_OPTS variable Parameters:
JAVA_OPTS = “$ JAVA_OPTS -Xms3072m -Xmx3072m -Xmn1536m \
-XX: PermSize = 384m -XX: MaxPermSize = 384m -XX: + UseConcMarkSweepGC \
-XX: + UseCMSCompactAtFullCollection -XX : CMSMaxAbortablePrecleanTime = 500 \
-XX: + CMSClassUnloadingEnabled -XX: + CMSClassUnloadingEnabled -Djava.util.logging.manager = org.apache.juli.ClassLoaderLogManager ”

-server: tomcat default is a java -client model to run, the server means that your tomcat is the real production mode in the operation of the better performance
-Xms-Xmx: JVM memory settings, JVM initial The allocated heap memory is specified by -Xms and defaults to 1/64 of the physical memory. The maximum allocated heap memory for the JVM is specified by -Xmx, which is 1/4 of the physical memory by default. When the default free heap memory is less than 40%, the JVM will increase the heap until the maximum limit of -Xmx. When the
free heap memory is greater than 70%, the JVM will reduce the heap until the minimum limit of -Xms. It is recommended to set the maximum and minimum Conducive to the JVM garbage collection mechanism
-Xmn: set the new generation, the size of the heap = new generation size + older generation size + lasting generation size. This value has a significant impact on system performance. Sun’s official recommendation for the entire heap 3/8
-XX: Whenever the JDK version is upgraded, your JVM will use the latest addition of the optimization technology –
XX: PermSize: set non-heap memory initial Value, the default is the physical memory of the 1/64
-XX: MaxPermSize: set the eternal generation memory initial size, that is, the maximum non-heap memory size, the default is the physical memory 1 /
4XX: + UseConcMarkSweepGC: CMS gc, this feature Only jdk1.5 that follow-up version has the function, it uses the gc estimate trigger and heap occupancy trigger
-XX: + UseCMSCompactAtFullCollection: in the case of the use of concurrent gc, to prevent memoryfragmention, the live object to organize the memory fragments to reduce
-XX: + UseParNewGC: on the new generation of multi-threaded parallel recovery, so close fast-
XX: + CMSClassUnloadingEnabled: CMS collector will not be the default generation of garbage collection
-XX: CMSMaxAbortablePrecleanTime: CMS GC needs to go through more steps to complete a GC action, in the case of minor GC more frequent, it is likely to cause the CMS GC has not yet completed, resulting in concurrent mode failure, you can-xX: CMSMaxAbortablePrecleanTime set Small values ??to ensure that CMS GC completes object recovery as soon as possible and avoids concurrent mode failure, especially in versions of JDK 5.0 +, 6.0+ on CMS-concurrent-abortable-preclean-start and CMS-concurrent-abortable -preclean These two steps may take a long time, resulting in the recovery of the old generation of objects for a long time before being recovered, this is a Sun JDK CMS GC bug

Second, Tomcat server.xml configuration file

The common configuration performance tuning configuration in Tomcat is as follows:

connectionTimeout: timeout time in milliseconds, the default value is 60000, that is, 60 seconds
maxThreads: tomcat: the maximum number of threads starting, the default value of 200
minSpareThreads: Tomcat initialization to create the number of threads. Default value 4
maxProcessors: Tomcat runtime to create the maximum number of threads, the default value of 75, generally based on the actual production environment to modify
acceptCount: tomcat started when the maximum number of threads to accept the number of queued requests, the default value of 100, web server allows the maximum number of connections is also subject to the operating system kernel parameter settings, usually Windows is about 2000, Linux is about 1000, usually the same as the value set
maxThreads enableLookups: whether the anti-check domain name, the default value is true. In order to improve the processing power, should be set to false
compression: compressed transmission, the value on / off / force, the default value off
redirectPort: SSL redirect port, the default 8443

In short, in the usual need to modify the actual production conditions, Tomcat reasonable performance tuning, Tomcat will be the overall performance will be greatly improved.

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>