4

Strangely, i was unable to find in Google clear answer to NIO.2 async IO performance vs using NIO's multiplexed IO via java.nio.channels.Selector.

So, my question is: Does NIO.2 AsynchronousChannel have better performance than NIO Selector? Of course, i'm interested in server side of things under different load profiles - number of simultaneous connections/average connection lifetime/traffic.

The only information i was able to find is that Windows IOCP is slightly better than Windows select.

3
  • Or you could just use thread-based I/O... It performs well, and more often than not better than async I/O.
    – fge
    Dec 18, 2014 at 7:36
  • Both are for different purpose. Having said that with selector you can effectively reduce CPU and memory hogging because you are on single thread. This also helps in debugging. More threads = more pain
    – Dexter
    Dec 26, 2014 at 8:05
  • Have a look on opinion of Tomcat committer at stackoverflow.com/questions/77622056/…
    – igor.zh
    Dec 20, 2023 at 17:33

1 Answer 1

5

I don't think NIO.2 will have better performance than NIO, because NIO.2 still make use of select/poll system calls and thread pools to simulate asynchronous IO. One example is that Netty removed NIO.2 support in 4.0.0, because the author think that NIO.2 doesn't bring better performance than NIO in Linux platform.

2
  • Link you provided is really helpful. People mentioned there that since Windows7 selector performance is not that bad Jan 4, 2016 at 10:49
  • Yes, because IOCP in Windows enables asynchronous IO operation, although it is also implemented by threads pool, but the implementation is in the Kernel level, so it achieves some performance enhancement. Jan 4, 2016 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.