2

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

6 Answers 6

4

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. ;)

Sign up to request clarification or add additional context in comments.

Comments

1

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.

3 Comments

"Data would suggest that Java NIO scales better, JBOSS maintains and uses it now." This interests me. Could you point me to some reading material regarding this better scalability?
Maybe Googling for "java nio scalability" will give you things like this: javanio.info/filearea/nioserver/NIOServerMark2.pdf
This shouldn't be the accepted answer. As noted below, Tomcat has been able to use the NIO connector for years. Tomcat is a superset that has no need to use Netty. Tomcat performance is likely the best among Java EE servlet containers.
1

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.

Comments

1

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.

Comments

0

Implement a customized Server with Java Nio and and change the message structure a little bit then you can deal with all kinds of requests and responses. using-java-nio-socket-as-the-underlying-foundation-similar-to-tomcat

Comments

-1

Actually, this is should be closed. Tomcat has supported NIO for years, there is no need to talk about it now.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.