Tomcat/web server vs. Java NIO/Networking Framewor

2019-04-02 18:41发布

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

4条回答
看我几分像从前
2楼-- · 2019-04-02 18:53

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.

查看更多
可以哭但决不认输i
3楼-- · 2019-04-02 19:09

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.

查看更多
萌系小妹纸
4楼-- · 2019-04-02 19:12

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

查看更多
做个烂人
5楼-- · 2019-04-02 19:14

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.

查看更多
登录 后发表回答