tags:

views:

665

answers:

2

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 ?

A: 

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.

Tom Hawtin - tackline
+2  A: 

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.

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.

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.

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.

RogerV