Monday, May 2, 2011

When to use and when to prefer java.nio ?

1. Scalability will probably drive your choice of package. will require one thread per socket. Coding it will be significantly easier. java.nio is much more efficient, but is difficult to code around.
2. You may get better scalability once you are dealing with tens of thousands of connections, but at lower numbers you’ll probably get better throughput with blocking IO.
3. When working with SSL java.nio is not some thing easy to deal with
Important : If you are working with either of the packages, it is not a good idea to create the framework from scratch until and unless you have a compelling reason to do so.
For java.nio , the projects such as Grizzly and Quick Server provide reusable non blocking server components.
Worth reading Paint points with java.nio
Finally it boils down to specific requirements of your projects and what you are trying to achieve. Some of the best solutions may not require the most complex infrastructure at all!

No comments:

Post a Comment