Performance comparison of Tomcat's four connectors based on HTTP protocol

Performance comparison of Tomcat's four connectors based on HTTP protocol

Today I saw a performance comparison of four HTTP-based Connectors for Tomcat on osc

The details are as follows:


<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" Let's name the above four connectors as NIO, HTTP, POOL, NIOP in order
               redirectPort="8443" />



In order not to let other factors affect the test results, we only test a very simple jsp page, which just outputs a Hello World. Assuming that the address is http://tomcat1/test.jsp

, we will test the four connectors in turn. The test client is completed with the ab command on another machine. The test command is: ab -c 900 -n 2000 http: //tomcat1/test.jsp , the final test results are shown in the following 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 not difficult to see from these five sets of data that the performance of HTTP is very stable, but it is also the worst, and this method is the default configuration of Tomcat. The NIO mode fluctuates greatly, but none is lower than 280. NIOP adds a thread pool on the basis of NIO. It may be that the program processing is more complicated, so the performance is not necessarily better than NIO; while the POOL mode fluctuates greatly, and during the test Like the HTTP way, there are stagnations from time to time.

Since the Linux kernel limits the maximum number of open files to 1024 by default, the concurrency number is controlled at 900 this time.

Although this result is caused by various factors in the actual website, the difference may not be so big, such as limited by the performance of the database and so on. But it still has reference value for us when deploying website applications.

 

复制代码
<Connector
executor="tomcatThreadPool"
port="8090"
redirectPort="8443"
protocol="org.apache.coyote.http11.Http11NioProtocol"
compression="on"
compressionMinSize="2048"
enableLookups="false"
acceptCount="1000"
URIEncoding="UTF-8"
connectionTimeout="40000" />
复制代码

连接器使用的线程池的名子:executor="tomcatThreadPool" 
连接器端口                        :port="8090" 
连接器使用的传输方式      :protocol="org.apache.coyote.http11.Http11NioProtocol" 
传输时是否支持压缩          :compression="on" 
压缩的大小                        :compressionMinSize="2048"

<Executor name="tomcatThreadPool" namePrefix="catalina-exec-" 
        maxThreads="800" minSpareThreads="400" maxSpareThreads="700"/>

线程池名:           name="tomcatThreadPool" 
线程前缀:           namePrefix="catalina-exec-"
最大产生线程数:maxThreads="800"

最小初始现程数:minSpareThreads="400" 

最大初始现程数:minSpareThreads="700"

原文章地址:https://www.cnblogs.com/sunxucool/archive/2013/07/31/3227366.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324516443&siteId=291194637