Is non-blocking I/O really faster than multi-threaded blocking I/O? How?

后端 未结 9 1331
礼貌的吻别
礼貌的吻别 2020-11-29 15:09

I searched the web on some technical details about blocking I/O and non blocking I/O and I found several people stating that non-blocking I/O would be faster than blocking I

9条回答
  •  没有蜡笔的小新
    2020-11-29 15:44

    Let me give you a counterexample that asynchronous I/O does not work. I am writing a proxy similar to below-using boost::asio. https://github.com/ArashPartow/proxy/blob/master/tcpproxy_server.cpp

    However, the scenario of my case is, incoming (from clients side) messages are fast while outgoing (to server side) is slow for one session, to keep up with the incoming speed or to maximize the total proxy throughput, we have to use multiple sessions under one connection.

    Thus this async I/O framework does not work anymore. We do need a thread pool to send to the server by assigning each thread a session.

提交回复
热议问题