Tomcat's operating mode (3 types)

Source: Internet
Author: User

Tomcat supports three processing of receive requests:BIO,NIO,APR

(1) BIO mode: Blocking I/O operations, indicating that Tomcat is using a traditional JavaI/O operations ( i.e. Java. IO Package and its child packages ) . TOMCAT7 The following versions are run in bio mode by default , because each request is created with one thread to handle, the thread overhead is high, it cannot handle highly concurrent scenarios, and the performance is minimal in three modes.

(2) NIO mode: Yes Java SE1.4and subsequent versions of a newI/Ooperation mode(thatJava.niopackage and its child packages). is a buffer-based, and can provide non-blockingI/Ooperation ofJava API, it has more than the traditionalI/OOperation(bio)better concurrency running performance. Want to makeTomcatinNiOmode to run is relatively simple, justTomcatinstallation directory/conf/server.xmlThe file will be configured as follows:

<connector port= "8080" protocol= "http/1.1"

connectiontimeout= "20000"

redirectport= "8443"/>

Modified to:

<connectorport= "8080" protocol= "Org.apache.coyote.http11.Http11NioProtocol"

connectiontimeout= "20000"

redirectport= "8443"/>

Note: Tomcat8 the above version, the default is to use NIO mode, no additional modifications required  

(3) Apr (Apche Portable runtime):

Tomcat can use the Apache Portable runtime to provide superior scalability, performance, and better integration with local server technology. Apache Portable Runtime is the core of highly portable libraries for Apache HTTP Server 2. X. April has many uses, including access to advanced IO features (such as Sendfile Epoll and OpenSSL), operating system-level features (random number generation, System State, etc.), and local process processing (shared memory, NT pipeline, and UNIX sockets).
These features allow the Tomcat generic network server, which will make better with other on-premises web technologies, integrate and overall make Java more viable as a complete Web server platform rather than a simple back-end technology. ( to resolve asynchronous IO issues from the OS level )

How APR is implemented:

Package: http://apache.fayea.com//apr/apr-1.5.2.tar.gz

Http://apache.fayea.com//apr/apr-util-1.5.4.tar.gz

( 3.1 ) Installation APR tomcat-native

Software version:

Apr-1.5.2.tar.gz

Apr-util-1.5.4.tar.gz

installed in /USR/LOCAL/APR under

TAR-ZXVF apr-1.5.2.tar.gz

CD apr-1.5.2

./configure && Make && Makeinstall

TAR-ZXVF apr-util-1.5.4.tar.gz

CD apr-util-1.5.4

./configure--WITH-APR=/USR/LOCAL/APR--WITH-JAVA-HOME=JDK

Make && make install

CD Apache-tomcat-7.0.65/bin

TAR-ZXVF tomcat-native.tar.gz

CD tomcat-native-1.1.33-src/jni/native

./configure--WITH-APR=/USR/LOCAL/APR

Make && make install

(3.2) set tomcat integration APR

edit $TOMCAT _home/bin/ catalina.sh file, in virtual machine startup parameters java_opts add java.library.path APR path to library

catalina_opts= "$CATALINA _opts-djava.library.path=/usr/local/apr/lib"

Tomcat8 in the following versions, you need to specify the operating mode Protocol from http/1.1 Change into Org.apache.coyote.http11.Http11AprProtocol

< connector port = "8080" protocol Span style= "font-family: ' Courier New '; Font-size:16px;color:rgb (0,102,102);" >= "Org.apache.coyote.http11.Http11AprPr Otocol "

ConnectionTimeout = "20000"

Redirectport = "8443" />

Run Tomcat , you can check in the log to see if it is turned on Apr mode.




This article from "Wang Xiao Acid" blog, reproduced please contact the author!

Tomcat's operating mode (3 types)

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.