Currently for a class, I'm implementing a server which receives two types of connections, using TCP, and a custom application layer protocol. Though for the class, this is how the project needs to be done, I was wondering about the advantages/disadvantages of using something like Tomcat or a similar web server to receive all incoming communication, vs. using Java's NIO or a networking framework like Mina (which I'm using) or Netty (which I want to play around with at some point).
Though I'm asking about Java (because it's what I'm most comfortable with) specifically, you are more than welcome to expand this to any other languages.
I'm looking for comments on performance, ease of use, scalability (both in how well it scales development wise and usage wise), security, and any other base you think you may put information on.
Anyways, any input would be greatly appreciated.
Regards, Omar Ferrer
I think history sheds some light on the answer.
Tomcat predates Java NIO by many years. The thinking at the time that a queue for incoming requests and a pool of threads, one thread per request was best.
Data would suggest that Java NIO scales better, JBOSS maintains and uses it now.
I would not be surprised to learn that Tomcat was being refactored to use Netty.
Tomcat is traditionally used with Java Servlets and HTTP. If you are building a web application using Java then Tomcat is the way to go. If you simply want to comunicate using TCP/IP between two programs then it would probably be easier to use a network framework.
Tomcat itself has been able to use NIO since the release of version 6, with the NIO connector. So, NIO goodness, and Tomcat been beat up all over the place solidarity. I know which one I'm choosing. ;)
IMHO, the advantage of Tomcat exists when you are dealing with HTTP. For HTTP I would use Tomcat as it simplifies a lot of things, but for pure TCP I see no advantage so I would recommend using more simple methods.