简体   繁体   English

Tomcat在我的VM上运行缓慢,但在Eclipse中却没有

[英]Tomcat is slow on my VM, but not in Eclipse

I have a webapp that was previously deployed like this on my VM : 我有一个以前在VM上部署过的webapp:

  • One War containing the core 一战包含核心
  • JAR of all Dependancies were given to Tomcat by adding them in CLASSPATH 通过将所有依赖关系的JAR添加到CLASSPATH中,将它们提供给Tomcat

=> My application took around 1 min to start =>我的应用大约花了1分钟才能启动

I am working on apply some "best practices" on that web app, and I firstly work on the dependency inclusion. 我正在努力在该Web应用程序上应用一些“最佳实践”,并且首先致力于依赖项包含。 Now the webapp looks like this : 现在,webapp看起来像这样:

  • One War containing the core (WEB-INF/classes) and all dependencies (WEB-INF/lib) 一战,包含核心(WEB-INF /类)和所有依赖项(WEB-INF / lib)

In my Eclipse, there's no lag when starting the server, it takes around 2 mins. 在我的Eclipse中,启动服务器没有任何延迟,大约需要2分钟。 But on my VM, it now takes around 5 mins. 但是在我的VM上,现在大约需要5分钟。

I would like to know if the old webapp deployment was a good practice ? 我想知道旧的Webapp部署是否是一个好习惯? And if it's normal to have that long startup time (for me). 并且,如果有那么长的启动时间(对我来说)是正常的。

Thanks. 谢谢。

If you are starting tomcat on a headless server, it can take a long time to gather enough entropy for the SecureRandom which generates sessionIds. 如果要在无头服务器上启动tomcat,则可能需要很长时间才能为生成sessionId的SecureRandom收集足够的熵。 This should however only affect startup. 但是,这只会影响启动。 You can read more about How do I make Tomcat startup faster here. 您可以在此处阅读有关如何使Tomcat更快启动的更多信息。

Otherwise you have to look at the CPU and memory utilization, and enable Info/debug logging so you can see where Tomcat uses the time. 否则,您必须查看CPU和内存利用率,并启用信息/调试日志记录,以便可以看到Tomcat在哪里使用时间。

In my Eclipse I modified eclipse.ini as -Xms512m -Xmx2048m -XX:MaxPermSize=2048m 在我的Eclipse中,我将eclipse.ini修改为-Xms512m -Xmx2048m -XX:MaxPermSize = 2048m

and In tomcat Attributes in eclipse I modified, -Xms512m -Xmx1024m -XX:PermSize=1024m -XX:MaxPermSize=1024m 和我在Eclipse中的tomcat属性中修改的-Xms512m -Xmx1024m -XX:PermSize = 1024m -XX:MaxPermSize = 1024m

///My machine having 8GB of RAM ///我的机器有8GB的RAM

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

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