Three Tomcat modes and concurrent tuning, and tomcat Tuning

Source: Internet
Author: User
Tags reverse dns xms

Three Tomcat modes and concurrent tuning, and tomcat Tuning

Three Tomcat modes and concurrent optimization.

Three Tomcat running modes are available: BIO, NIO, and APR. These three types are described as follows: 1. bio

The default mode has very low performance and has not been optimized or supported.

2. nio

Using java asynchronous io Nursing Technology and noblocking IO technology.

To run in this mode, directly modify the ctor node in server. xml and SET protocol

It takes effect after being started.

3. apr

It solves asynchronous IO problems at the operating system level and greatly improves performance.

Apr and native must be installed. apr and native can be directly started.

Modify protocol to org. apache. coyote. http11.Http11AprProtocol

Install apr

Yum-y install apr-devel

Install native

Enter the tomcat/bin directory, for example:

Cd/usr/local/tomcat/bin/

Tar xzfv tomcat-native.tar.gz

Cd tomcat-native-1.1.20-src/jni/native/

./Configure -- with-apr =/usr/bin/apr-1-config

Make

Make install

After the installation is complete, the following message is displayed:

Libraries have been installed in:
/Usr/local/apr/lib

After the installation is successful, you also need to set environment variables for tomcat by adding one line to the catalina. sh file:

CATALINA_OPTS = "-Djava. library. path =/usr/local/apr/lib"

Modify conf/server. xml corresponding to terminal 8080

Protocol = "org. apache. coyote. http11.Http11AprProtocol"

After tomcat is started, this line of information is displayed in the view log, indicating that it has been started in APR mode.

INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].

Concurrency optimization 1) JVM Optimization

Add the following statement in TOMCAT_HOME/bin/catalina. sh. The specific value depends on the situation.

Add it to CATALINA_OPTS above:

JAVA_OPTS = "-Xms1024m-Xmx1024m-Xss1024K-XX: PermSize = 64 m-XX: MaxPermSize = 128 m"

Parameters:

-Xms JVM initialization heap memory size

-Maximum memory of Xmx JVM heap

-Xss thread stack size

-XX: PermSize: initial memory allocation in non-heap JVM

-XX: MaxPermSize JVM maximum non-heap memory

Suggestions and precautions:

-The Xms and-Xmx options are set to the same heap memory allocation to avoid adjusting the heap size after each GC. The heap memory is recommended to occupy 60% of the memory size ~ 80%; non-heap memory is not recoverable, depending on the project; the thread stack size is recommended to be 256 k.

The 32 GB memory configuration is as follows:

JAVA_OPTS = "-Xms20480m-Xmx20480m-Xss1024K-XX: PermSize = 512 m-XX: MaxPermSize = 2048m"

2) Disable reverse DNS query

In

EnableLookups = "false"

3) Optimize tomcat parameters (using APR)

Protocol = "org. apache. coyote. http11.Http11AprProtocol"
OnnectionTimeout = "20000" // connection timeout period
RedirectPort = "8443"
MaxThreads = "500"
MinSpareThreads = "20"
AcceptCount = "1000"
EnableLookups = "false"
URIEncoding = "UTF-8"/>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.