What is the difference between Tomcat's BIO Connector and NIO Connector?

前端 未结 4 1827
囚心锁ツ
囚心锁ツ 2020-12-02 05:51

I would like to know the internals of the tomcat NIO connector. How exactly are threads used when we create a servlet that implements CometProcessor?Is it still one thread p

4条回答
  •  难免孤独
    2020-12-02 06:42

    NIO use fewer thread, it means that the tcp/ip port use is fewer.

    You know the port is 1 to 65534, so we can say that NIO can reach a higher TPS (Transactions Per Second) than BIO

    I tested both protocol :HTTP/1.1 and org.apache.coyote.http11.Http11NioProtocol with same web-project, same host, and same server.xml but the protocol.

    Use jmeter for test.

    I set 1000 thread to run request, when HTTP/1.1 in a few minutes, the host use port is more than 30000 and the TPS is 300 only!

    When org.apache.coyote.http11.Http11NioProtocol, the max count of use port is never overstep 3000 and the tps is more than 1200!

提交回复
热议问题