1

我们成功地将 Web 应用程序从 Weblogic 迁移到了 tomcat 7。Web 应用程序是使用构建的。

  1. 春天
  2. jsp
  3. 使用 weblogic 数据源

当我们迁移到 Tomcat 时,我们开始使用 DBCP。但考虑更改为 Tomcat JDBC 连接池。请建议这会有所帮助。

应用程序必须在服务器端执行一些繁重的事务。

但是 tomcat 无法提供我们在 weblogic 中获得的性能和稳定性。

在 tomcat 上运行的 GC 线程太多,这导致应用程序挂起。几乎 2/7 的总时间花在 GC 上。

这是JVM初始化字符串

JAVA_OPTS="$JAVA_OPTS -server -Xms120G -Xmx120G -Xmn60G -XX:PermSize=512m -XX:MaxPermSize=512m -XX:MaxNewSize=40G -XX:NewSize=40G -Xloggc:$CATALINA_HOME/logs/gc.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+DisableExplicitGC -XX:+CMSClassUnloadingEnabled -XX:+UseLargePages -XX:LargePageSizeInBytes=1200m"

请帮助我调整 tomcat 以获得更好的性能和稳定性。

4

1 回答 1

3

A few questions immediately jump out:

  • What profiling and analysis have you done to lead you to believe that you need 120 GiB of heap space?
  • Are you aware of the GC implications of a very large heap?
  • Do you have enough physical memory for the entire Java process, not just the heap?
  • Why are you explicitly setting the max size of the young generation to 60 GiB and new to 40 GiB?

If we take a look at the options you've specified:

-server 
-Xms120G 
-Xmx120G 
-Xmn60G 
-XX:PermSize=512m 
-XX:MaxPermSize=512m 
-XX:MaxNewSize=40G 
-XX:NewSize=40G 
-XX:+PrintGCDetails 
-XX:+PrintGCTimeStamps 
-XX:+UseConcMarkSweepGC 
-XX:+CMSIncrementalMode 
-XX:+DisableExplicitGC 
-XX:+CMSClassUnloadingEnabled 
-XX:+UseLargePages 
-XX:LargePageSizeInBytes=1200m

It reads like a list by someone who's read one too many 'Java performance' blogs. If you can't explain what each option does and why you've added it as an argument, remove the option.

Typically, the JVM handles itself well - often making better decisions about things like how much eden space it needs etc. If you're going to set much more than the heap and perm gen sizes (and even then...) you really need to know what you're doing...

Unfortunately, there are no magic settings and that's especially true if your application is particularly heavy.

Start from a set of realistic base settings, use tools like JVisualVM, JMeter, MAT et al. to look at an overview of the behaviour of your application. Record metrics on performance, heap usage, concurrent threads, throughput (peak and average), time spent doing garbage collection and the stability of your app. Each time you make a change, record the same metrics and record the results. Eventually, you'll have an application tuned properly and you'll understand whether each setting is actually having a positive effect on performance.

于 2013-02-14T09:53:08.027 回答