1

I am designing a server for a remote file store in Java and trying to decide whether to use asynchronous java.nio.SocketChannels or the older blocking model with Sockets. What kind of factors should I consider when choosing between these two server architectures and what kinds of tasks would be better suited to one versus the other?

Specifically, I am wondering how these respective approaches compare as:

  1. the number of connected clients scale up,
  2. the length of a client connection increases, and
  3. the amount of data transferred increases.

Also, are there any other factors that I should be aware of that would favor one approach over the other?

  • 2
    What factors are you considering right now? And have you done any research? For instance, does this help: stackoverflow.com/questions/2625493/… ? – Jay Elston Mar 4 '15 at 1:34
  • Right now I'm trying to consider how these frameworks compare as the number of connected clients scale up and as the length of a client connection/amount of data transferred increases. I am already familiar with the related definitions. – Matthew Loring Mar 5 '15 at 16:07
1

Why are you trying to solve an already solved problem? There already exists at least two good ones:

Grizzly

Writing scalable server applications in the Java™ programming language has always been difficult. Before the advent of the Java New I/O API (NIO), thread management issues made it impossible for a server to scale to thousands of users. The Grizzly NIO framework has been designed to help developers to take advantage of the Java™ NIO API. Grizzly’s goal is to help developers to build scalable and robust servers using NIO as well as offering extended framework components: Web Framework (HTTP/S), WebSocket, Comet, and more!

Netty

Netty is a NIO client server framework which enables quick and easy development of network applications such as protocol servers and clients. It greatly simplifies and streamlines network programming such as TCP and UDP socket server.

'Quick and easy' doesn't mean that a resulting application will suffer from a maintainability or a performance issue. Netty has been designed carefully with the experiences earned from the implementation of a lot of protocols such as FTP, SMTP, HTTP, and various binary and text-based legacy protocols. As a result, Netty has succeeded to find a way to achieve ease of development, performance, stability, and flexibility without a compromise.

It sounds to me like you are less interested in solving the problem yourself than you are in just having the problem be solved - so you can have your remote file store. Personally, I use Netty in my application and it works great. Don't reinvent the wheel - use someone else's.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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