原文见CodeWeblog.com 见中文
tomcat connector (conncector) can be configured way NIO IO and NIO today were nothing to do on the next test configuration is as follows:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" executor="tomcatThreadPool" />
<Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol" connectionTimeout="20000" redirectPort="8443" />
Test two main resources:
Dynamic pages (with database queries, emphasis on IO and cpu) -- 动态页面(db查询,偏重消耗IO和CPU)
Static pages (no database operations, mainly on the ability to handle a simple request) -- 静态页面(没有DB操作,主要是处理简单的请求)
The results are as follows:
Dynamic Page
Concurrency 100 200 300 400 600 800 IO 206 215 209 205 210 206 NIO 192 194 189 194 195 191
Static page
Concurrency 100 200 300 400 600 800 IO 941 306 361 361 347 400 NIO 927 313 318 703 286 914
Can be seen in dealing with the advantages of dynamic resources NIO is not obvious or even not as good as IO, the main reason is a dynamic resource, IO, and cpu-intensive operations, resulting in many requests are blocked on the CPU and IO, it can only dry socket IO waiting, not to play the advantages of NIO
NIO look at the performance when dealing with static, although the unstable but still very significant performance improvements, so NIO often used to process the request and deal with them more than simple applications, such as memcached
-- 看来,如果是比较耗CPU和IO的操作,tomcat即使在NIO的时候接收更大的并发,那么,顶多是进一步榨干机器的IO和CPU,还有可能将机器崩溃掉。因此,一定要参考CPU和IO的情况,有DB的话,也要参考DB机器的CPU和IO。这时候,估计还是增加更多的机器和应用,以此降低机器的负荷。
附:tomcat的官方文档上对集中connector的对比:
Below is a small chart that shows how the connectors differentiate.
Java Blocking Connector Java Nio Blocking Connector APR Connector
Classname Http11Protocol Http11NioProtocol Http11AprProtocol
Tomcat Version 3.x 4.x 5.x 6.x 6.x 5.5.x 6.x
Support Polling NO YES YES
Polling Size N/A Unlimited - Restricted by mem Unlimited - Configurable
Read HTTP Request Blocking Non Blocking Blocking
Read HTTP Body Blocking Sim Blocking Blocking
Write HTTP Response Blocking Sim Blocking Blocking
SSL Support Java SSL Java SSL OpenSSL
SSL Handshake Blocking Non blocking Blocking
Max Connections maxThreads See polling size See polling size
|