简体   繁体   English

在Cpanel服务器中部署多个Tomcat应用程序时出现内存泄漏问题

[英]Memory leak issue in deploying multiple Tomcat application in Cpanel Server

We have tried to deploy multiple tomcat applications in Cpanel server and we are facing the memory issue quite often. 我们尝试在Cpanel服务器中部署多个tomcat应用程序,我们经常遇到内存问题。 When we are running a single tomcat application it works fine without any issues but when running two applications this causes the %CPU to increase above 250 and both the application becomes stuck. 当我们运行单个tomcat应用程序时,它运行正常,没有任何问题,但是当运行两个应用程序时,这会导致%CPU增加到250以上并且应用程序都会卡住。 Can anyone please help us on this? 谁能帮助我们呢? Please see the error shown in log below. 请参阅下面的日志中显示的错误。

org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.OutOfMemoryError: PermGen space

Exception in thread "http-bio-80-exec-1206" java.lang.OutOfMemoryError: PermGen space
Exception in thread "http-bio-80-exec-1195" java.lang.OutOfMemoryError: PermGen space
#

You will need to tweak and optimize the server for proper resource usages and as the Java apps that you are running and running out of Memory. 您需要调整和优化服务器以获得适当的资源使用,以及正在运行和耗尽内存的Java应用程序。

what server configuration do you have ? 你有什么服务器配置? is it a VPS or a dedicated server ? 它是VPS还是专用服务器?

or you are using shared hosting ? 或者您正在使用共享主机?

  • Are you in production environment? 你在生产环境吗?
  • Exception appear exactly at deployment stage or at the first usage of your app? 是否在部署阶段或首次使用应用时出现异常?
  • Your apps are ligth (microservices) or are monolithics apps ? 您的应用程序是ligth(微服务)还是单片应用程序? Xms and -Xmx arguments depend of that. Xms和-Xmx参数取决于此。

When you deploy a war file in tomcat, some section of tomcat java memory are used and is not well-managed by tomcat. 在tomcat中部署war文件时,会使用某些tomcat java内存部分,并且tomcat无法很好地管理它。 A proof of that is if you deploy several times the same app without restart, an outofmemory appear in tomcat log. 一个证明就是如果您在不重新启动的情况下多次部署相同的应用程序,则会在tomcat日志中显示一个outofmemory。

If you are in production environment: 如果您在生产环境中:

  • Use one tomcat by app. 使用一个tomcat by app。 So you can deploy, stop, start, restart, etc this app without risk of impact other apps. 因此,您可以部署,停止,启动,重启等应用此应用,而不会有影响其他应用的风险。 If you restart tomcat after one deploy, memory errors at deployment stage go away. 如果在一次部署后重新启动tomcat,则部署阶段的内存错误将消失。

  • Use tomcat-docker. 使用tomcat-docker。 With docker your could kill the entire tomcat ad start a new instance in each deploy. 使用docker可以杀死整个tomcat广告,在每个部署中启动一个新实例。 So your tomcat would be clean. 所以你的tomcat会很干净。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM