Can the thread per request model be faster than non-blocking I/O?

后端 未结 4 2151
你的背包
你的背包 2021-02-09 00:34

I remember 2 or 3 years ago reading a couple articles where people claimed that modern threading libraries were getting so good that thread-per-request servers would not only be

4条回答
  •  不思量自难忘°
    2021-02-09 00:55

    It is faster as long as there is enough memory.

    When there are too many connections, most of which are idle, NIO can save threads therefore save memory, and the system can handle a lot more users than thread-per-connection model.

    CPU is not a direct factor here. With NIO, you effectively need to implement a threading model yourself, which is unlikely to be faster than JVM's threads.

    In either choice, memory is the ultimate bottleneck. When load increases and memory used approaches max, GC will be very busy, and the system often demonstrate the symptom of 100% CPU.

提交回复
热议问题