为什么Netty使用NIO而不是AIO?

NIO VS AIO

理论上,AIO是真正的异步IO,IO吞吐量是要高于NIO的。两种IO模式的概念如下:

  1. NIO:IO复用模型,仍是阻塞IO,通过复用IO线程提升吞吐量;
  2. AIO:线程A执行IO操作时,注册回调函数,当IO操作执行完成后,内核通知应用层,由线程B执行回调逻辑;

为什么Netty使用NIO而不是AIO?

原因:在Linux系统上,AIO的底层实现仍使用EPOLL,与NIO相同,因此在性能上没有明显的优势;Windows的AIO底层实现良好,但是Netty开发人员并没有把Windows作为主要使用平台考虑。

We obviously did not consider Windows as a serious platform so far, and that’s why we were neglecting NIO.2 AIO API which was implemented using IOCP on Windows. (On Linux, it wasn’t any faster because it was using the same OS facility - epoll.)

参考:

  1. https://github.com/netty/netty/issues/2515

猜你喜欢

转载自blog.csdn.net/yangguosb/article/details/80053731