Tomcat starts with version 5.5 and supports the following four types of connector configurations, respectively:
<connector port= "8081" protocol= "Org.apache.coyote.http11.Http11NioProtocol" connectiontimeout= "20000" redirectport= "8443"/>
<connector port= "8081" protocol= "http/1.1" connectiontimeout= "20000"
redirectport= "8443"/>
<connector executor= "Tomcatthreadpool"
Port= "8081" protocol= "http/1.1"
connectiontimeout= "20000"
redirectport= "8443"/>
<connector executor= "Tomcatthreadpool"
Port= "8081" protocol= "Org.apache.coyote.http11.Http11NioProtocol"
connectiontimeout= "20000"
redirectport= "8443"/>
Let's just name the above four connector in the order of NIO, HTTP, POOL, NIOP
In order not to let other factors affect the test results, we only test a very simple JSP page, and this page simply outputs a Hello world. Assuming the address is http://tomcat1/test.jsp
We test four kinds of connector in turn, the test client on another machine with the AB command to complete, Test command is: Ab-c 900-n http://tomcat1/test.jsp, the final test results as shown in the table (unit: Average number of requests processed per second):
NIO HTTP POOL Niop
281 65 208 365
666 66 110 398
692 65 66 263
256 63 94 459
440 67 145 363
It is easy to see from these five sets that HTTP performance is stable, but it is the worst, and this is the default configuration for Tomcat. NiO is very volatile, but no less than 250, NIOP is on the basis of NIO to join the thread pool, it is possible that the program processing more complex, so the performance is not better than NIO, and the pool mode is very volatile, the test period and the same as the HTTP, and occasionally stalled.
Because the Linux kernel default limits the maximum number of open files is 1024, so this concurrency control at 900.
Although this results in the actual site because of various factors, may not be so different, such as limited by the performance of the database and so on. But it's also valuable to us when deploying Web applications.
Tomcat 6 supports NIO--Tomcat's four connector performance comparisons based on HTTP protocol (reprint)