在Tomcat中托管Netty服务器可行/可取? [英] Is hosting a Netty Server inside Tomcat feasible/desirable?

查看:526
本文介绍了在Tomcat中托管Netty服务器可行/可取?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在建立一个基于Netty / NIO的服务,我正在考虑在我们的生产环境中部署这项服务。我们的部署服务的标准方式是作为战争部署在Tomcats中。



当我在这里提出同样的做法时,我喊道:不应该因为Netty和Tomcat都是服务器,在另一个服务器上托管一个服务器并不合适。



对我来说,这是非常有道理的它完全解决了我的部署问题,也避免了我编写一些其他代码。为什么这么大的否?

解决方案

Tomcat提供的动态WAR部署和取消部署是为Web应用程序设计的。您尝试部署到Tomcat的Netty应用程序不是Web应用程序,而只是一个仅共享VM内存的单独服务器。这意味着Tomcat已经被重新利用到一个通用的微内核,如OSGi。



但是,我不认为这是一个大问题。由于您的公司使用WAR作为标准部署机制,因此重用它可能是个好主意。您甚至不需要编写一些管理功能,如远程关闭,因为Tomcat已经提供了它们。所有您需要做的是确保在取消部署时所有资源都被释放。



有些人可能不喜欢这种方法。理想情况下,应该有一个通用的基础架构,用于部署和管理任何应用程序(也称为微内核),甚至将Tomcat作为模块部署,而微内核则直接管理WAR而不是Tomcat。但这还有很长的路要走。


We building a Netty/NIO based service, and I'm considering the deployment of this service to our production environment. Our standard way of deploying services is as WARs, to be deployed inside Tomcats.

When I suggested the same approach here, I got shouts and complaints that "it shouldn't be done", because both Netty and Tomcat are servers, and "it doesn't make sense to host one server in another".

To me it makes perfect sense because it completely solves my deployment issue, as well as saves me from writing some other code. Why is it such a big "no no" ?

解决方案

The dynamic WAR deploying and undeploying that Tomcat provides are designed for web applications. The Netty application you are trying to deploy into Tomcat is not a web application but just a separate server that only shares the VM memory. It means Tomcat has been repurposed into a generic microkernel such as OSGi.

However, I don't think it's a big problem. Since your company uses WAR as the standard deployment mechanism, it might be a good idea to reuse it. You don't even need to write some management functions like remote shutdown because Tomcat already provides them. All you need to do is to make sure all resources are freed up when undeployed.

Some people might not like this approach though. Ideally, there should be a common infrastructure for deploying and managing whatever application (aka microkernel), where even Tomcat is deployed as a module and the microkernel manages WAR directly instead Tomcat does. But that's a long way to go.

这篇关于在Tomcat中托管Netty服务器可行/可取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆