Any experience on the tradeoffs in terms of nio vs bio when having heap and computationally intensive process executed for every query with execution times in (100ms-900ms) range ?
在执行时间为(100ms-900ms)的每个查询中执行堆和计算密集型过程时,在nio vs bio方面的权衡经验?
3 个解决方案
#1
The real issue is how many concurrent open connections do you want to be able to scale up to per physical server (say, to support server messaging push ala Comet pattern - and who doesn't want to do that these days?). NIO will get you realistically into the 10,000 to 20,000 range. Threads are an extremely expensive resource from the OS implementation point of view (per thread memory consumption and context switching overhead). So thousands of NIO connections can be sustained with modest thread pool.
真正的问题是,您希望能够扩展到每个物理服务器的并发开放连接数量(例如,支持服务器消息传递推送ala Comet模式 - 以及这些天谁不想这样做?)。 NIO将让您真实地进入10,000到20,000范围。从OS实现的角度来看,线程是一种非常昂贵的资源(每线程内存消耗和上下文切换开销)。因此,可以使用适度的线程池来维持数千个NIO连接。
Use a NIO framework like MINA and rolling NIO is not bad at all. (Pretty darn easy actually.) I've rolled my own NIO and then also incorporated MINA. MINA is a good way to go.
使用像MINA这样的NIO框架,滚动NIO也不错。 (实际上非常简单。)我已经推出了自己的NIO,然后还加入了MINA。 MINA是一个很好的方式。
http://mina.apache.org/testimonials.html
EURid used MINA during the landrush for .eu domain names on the 7th of april 2006. More than 700.000 domain names were registered during the first 4 hours. After one hour MINA had handled more than 0.5 million SSL connections.
EURid于2006年4月7日在.eu域名抢注期间使用MINA。在前4个小时内注册了超过700.000个域名。一小时后,MINA处理了超过50万个SSL连接。
We found the speed and stability of MINA to be excellent. And although we are still using MINA 0.8.1, we found the API very elegant and easy.
我们发现MINA的速度和稳定性非常好。虽然我们仍在使用MINA 0.8.1,但我们发现API非常优雅和简单。
#2
One thing that you should take in mind, is that are some reports of bugs in JVM for NIO, which causes Jetty to hang and uses 100% of CPU. So, for now, I recommend you to stay with BIO if you see this behavior. Related links:
您应该记住的一件事是,一些JVM for NIO中的错误报告,导致Jetty挂起并使用100%的CPU。所以,就目前而言,如果你看到这种行为,我建议你留在BIO。相关链接:
#3
Unless you are sending or receiving huge amounts of data, then CPU considerations will dominate. java.nio is more difficult to use than java.io (asynchronous I/O in JDK 7 will be somewhere between). If the amount of data exceeds buffering, then you might want to do I/O in a different thread.
除非您发送或接收大量数据,否则CPU占主导地位将占主导地位。 java.nio比java.io更难使用(JDK 7中的异步I / O介于两者之间)。如果数据量超过缓冲,那么您可能希望在不同的线程中执行I / O.
#1
The real issue is how many concurrent open connections do you want to be able to scale up to per physical server (say, to support server messaging push ala Comet pattern - and who doesn't want to do that these days?). NIO will get you realistically into the 10,000 to 20,000 range. Threads are an extremely expensive resource from the OS implementation point of view (per thread memory consumption and context switching overhead). So thousands of NIO connections can be sustained with modest thread pool.
真正的问题是,您希望能够扩展到每个物理服务器的并发开放连接数量(例如,支持服务器消息传递推送ala Comet模式 - 以及这些天谁不想这样做?)。 NIO将让您真实地进入10,000到20,000范围。从OS实现的角度来看,线程是一种非常昂贵的资源(每线程内存消耗和上下文切换开销)。因此,可以使用适度的线程池来维持数千个NIO连接。
Use a NIO framework like MINA and rolling NIO is not bad at all. (Pretty darn easy actually.) I've rolled my own NIO and then also incorporated MINA. MINA is a good way to go.
使用像MINA这样的NIO框架,滚动NIO也不错。 (实际上非常简单。)我已经推出了自己的NIO,然后还加入了MINA。 MINA是一个很好的方式。
http://mina.apache.org/testimonials.html
EURid used MINA during the landrush for .eu domain names on the 7th of april 2006. More than 700.000 domain names were registered during the first 4 hours. After one hour MINA had handled more than 0.5 million SSL connections.
EURid于2006年4月7日在.eu域名抢注期间使用MINA。在前4个小时内注册了超过700.000个域名。一小时后,MINA处理了超过50万个SSL连接。
We found the speed and stability of MINA to be excellent. And although we are still using MINA 0.8.1, we found the API very elegant and easy.
我们发现MINA的速度和稳定性非常好。虽然我们仍在使用MINA 0.8.1,但我们发现API非常优雅和简单。
#2
One thing that you should take in mind, is that are some reports of bugs in JVM for NIO, which causes Jetty to hang and uses 100% of CPU. So, for now, I recommend you to stay with BIO if you see this behavior. Related links:
您应该记住的一件事是,一些JVM for NIO中的错误报告,导致Jetty挂起并使用100%的CPU。所以,就目前而言,如果你看到这种行为,我建议你留在BIO。相关链接:
#3
Unless you are sending or receiving huge amounts of data, then CPU considerations will dominate. java.nio is more difficult to use than java.io (asynchronous I/O in JDK 7 will be somewhere between). If the amount of data exceeds buffering, then you might want to do I/O in a different thread.
除非您发送或接收大量数据,否则CPU占主导地位将占主导地位。 java.nio比java.io更难使用(JDK 7中的异步I / O介于两者之间)。如果数据量超过缓冲,那么您可能希望在不同的线程中执行I / O.