Tomcat connector comparison and optimization of three operating modes (BIO, NIO, APR)

Source: Internet
Author: User

The three different modes of operation of TOMCAT connector vary widely, with the results being tested as follows:
The differences between the three modes are as follows:
    • BIO:
A thread processes a request. Disadvantage: When the concurrency is high, the number of threads is much, wasting resources. TOMCAT7 or below, this method is used by default in Linux systems.
    • Nio:
With Java's asynchronous IO processing, a large number of requests can be processed through a small number of threads.
Tomcat8 is used this way by default in Linux systems. TOMCAT7 must modify the connector configuration to start: <connector port= "8080" protocol= "Org.apache.coyote.http11.Http11NioProtocol " connectiontimeout= "20000" redirectport= "8443"/>
    • APR:
thatApache Portable Runtime, addressed from the OS levelioblocking issues.
Tomcat7 or TOMCAT8 is started by default in Win7 or more systems in this way. Linux supports Apr if the APR is installed and Native,tomcat is launched directly. (Installation method: http://my.oschina.net/lsw90/blog/181161)
The official details of the three differences are as follows:java Blocking Connector java Nio Blocking Connector apr/native Connector
BIO NIO APR
Classname ajpprotocol ajpnioprotocol ajpaprprotocol
Tomcat Version 3.x onwards 7.x onwards 5.5.x onwards
Support Polling NO Yes Yes
Polling Size N/a maxconnections maxconnections
Read Request Headers Blocking Sim Blocking Blocking
Read Request Body Blocking Sim Blocking Blocking
Write Response Blocking Sim Blocking Blocking
Wait for next Request Blocking Non Blocking Non Blocking
Max Connections maxconnections maxconnections maxconnections
When Tomcat starts, you can see in log which mode of Operation Connector is using:
    • Starting Protocolhandler ["http-bio-8080"]
    • Starting Protocolhandler ["http-nio-8080"]
    • Starting Protocolhandler ["http-Apr-8080"]

(original article, reprint please specify the CSDN blog from Clement-xu)



Copyright NOTICE: This article is the original article, reprint please indicate the CSDN blog which is transferred from Clement-xu.

Tomcat connector comparison and optimization of three operating modes (BIO, NIO, APR)

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.