1.1 problem
Sometimes we also want to change the default bio mode of Tomcat to NiO mode, how do we change it?
1.2 Programme
Modify it through the server.xml inside Eclipse.
1.3 Steps
First, let's take a look at Eclipse's default Server.xml file
Noun Explanation:
Bio (blocking I/O), as the name implies, is a blocking I/O operation that indicates that Tomcat is using traditional Java I/O operations (that is, the Java.io package and its sub-packages). Tomcat, by default, is run in bio mode. Unfortunately, in general, the Bio mode performance is relatively underground. We can view the current state of the server through Tomcat Manager.
Where the AJP port is used for and server load balancing.
NIO (new I/O) is a new I/O operation (i.e. the Java.nio package and its child packages) provided by Java SE 1.4 and subsequent versions. Java NiO is a buffer-based, Java API that provides non-blocking I/O operations, so NiO is also considered an abbreviation for non-blocking I/O.
It has better concurrency performance than traditional I/O operations (bio). It's easier to make Tomcat run in NiO mode, we just need to configure the following in the Tomcat installation directory/conf/server.xml file:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="font-size: 14px !important; line-height: 21px !important; z-index: 0; opacity: 0; overflow: hidden"><connector port= "8080" protocol= "http/1.1" connectiontimeout= "20000" redirectport= "8443 "/></textarea>
123 |
<connector port = " 8080 " protocol = "http/1.1" connectiontimeout = "20000" redirectport = "8443" /> |
Change into
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="font-size: 14px !important; line-height: 21px !important; z-index: 0; opacity: 0; overflow: hidden"><connector port= "8080" protocol= "Org.apache.coyote.http11.Http11NioProtocol" connectiontimeout= "2000 0 "redirectport=" 8443 "/></textarea>
123 |
<connector port Span class= "Crayon-o" >= "8080" protocol = " Org.apache.coyote.http11.Http11NioProtocol " connectiontimeout = "20000" redirectport = "8443" /> |
If you need to modify the AJP, you can modify this, just
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="font-size: 14px !important; line-height: 21px !important; z-index: 0; opacity: 0; overflow: hidden"><connector port= "8009" protocol= "ajp/1.3" redirectport= "8443"/></textarea>
1 |
<connector Port = "8009" protocol="ajp/1.3" redirectport="8443" /> |
Change into
<textarea wrap= "soft" class= "Crayon-plain print-no" data-settings= "DblClick" readonly style= "Font-size:14px! Important LINE-HEIGHT:21PX!important; z-index:0; opacity:0; Overflow:hidden "><connector port=" 8009 "protocol=" Org.apache.coyote.ajp.AjpNioProtocol "redirectport=" 8443 "/ </textarea>
1 |
<connector Port = "8009" protocol="Org.apache.coyote.ajp.AjpNioProtocol" redirectport ="8443" /> |
To deploy the project, start Tomcat as follows:
If you think the quality of this tutorial is good, after reading the harvest is very large, the expected salary can rub against the upward, then I would like to small sponsorship, let me have the power to continue to write high-quality tutorials.
The development environment in Eclipse also wants to change Tomcat's default bio mode to NIO mode