在不重新启动的情况下将应用程序部署/重新部署到 Tomcat 的陷阱
我读到,使用 Tomcat 5.5+ 可以在不重新启动的情况下将战争部署到 Tomcat 服务器。这听起来很棒,但我想我对这个功能及其可靠性太怀疑了。我以前(使用 Websphere)的经验是,最好的做法是重新启动服务器以避免内存问题等。因此,我想获得有关 Tomcat 可能存在哪些陷阱的反馈。
(为了清楚地说明我的经验,我为一家大公司开发了 Java Web 应用程序 5 年,该公司将应用程序开发人员与应用程序服务器工程师分开 - 我们使用 Websphere - 所以我没有太多运行/配置任何应用程序的经验我自己的应用程序服务器)
I have read that it is possible with Tomcat 5.5+ to deploy a war to a Tomcat server without a restart. That sounds fantastic but I guess I am too skeptical about this functionality and it's reliability. My previous experience (with Websphere) was that it was a best practice to restart the server to avoid memory problems, etc. So I wanted to get feedback as to what pitfalls might exist with Tomcat.
(To be clear about my experience, I developed java web apps for 5 years for a large company that partitioned the app developers from the app server engineers - we used Websphere - so I don't have a lot of experience with running/configuring any app servers myself)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一般来说,存在多种类型的泄漏,它们适用于重新部署场景。对于生产系统,如果可能的话最好重新启动,因为当今的应用程序中使用了许多不同的组件和库,很难找到所有这些组件和库,甚至更难修复它们。特别是。如果您无法访问所有源代码。
类加载器泄漏会影响重新部署。
它们可能是由一切原因引起的。真的,我的意思是一切:
.war 文件。静态注册表造成的
特定于 Tomcat,我的经验如下:
我写了一篇关于 我在进行重新部署压力测试时遇到的泄漏问题 - 尝试“修复”企业级 Java Web 应用程序的所有可能的泄漏。
In general, there are multiple type of leaks and they apply to redeploy-scenarios. For production systems, it's really the best to perform restarts if possible, as there are so many different components and libraries used in todays applications that it's very hard to find them all and even harder to fix them. Esp. if you haven't got access to all source code.
ClassLoader leaks are the ones which bite at redeployment.
They can be caused by everything. Really, i mean everything:
.war
file anyway. Leak due to static registrySpecific to Tomcat, my experience is as follows:
org.apache.catalina.core.JreMemoryLeakPreventionListener
and was submitted recently to Tomcat 6.xI wrote a blog post about my experience with leaks when doing redeployment stresstesting - trying to "fix" all possible leaks of an enterprise-grade Java Web Application.
热部署非常好,因为它通常比启动和关闭服务器要快得多。
mhaller 写了很多关于避免泄漏的文章。另一个问题是活动用户的会话在应用程序“重新启动”后仍然存在。有几件事必须注意,但总而言之,这意味着它们的会话必须可序列化,然后才能正确反序列化。如果您有有状态的数据库连接等,这可能会有点棘手,但如果您的代码对于数据库故障具有鲁棒性,那么这应该不会太糟糕。
另请注意,某些 IDE 允许在保存修改后的源文件时更新 WAR 内的代码(与应用程序相同),而不必重新部署。 MyEclipse 在这方面做得相当好。
Hot deployment is very nice as it usually is much faster than bringing the server up and down.
mhaller has written a lot about avoiding leaks. Another issue is for active users to have their session survive the application "reboot". There are several things that must be taken care of, but which all in all means that their session must be serializable and THEN deserialize properly afterwards. This can be a bit tricky if you have stateful database connections etc, but if your code is robust against database hickups anyway that shouldn't be too bad.
Also note that some IDE's allow updating code inside the WAR (in the same way as applications) when saving a modified source file, instead of having to redeploy. MyEclipse does this rather nicely.