问题描述
我们最近从Tomcat 4迁移了一个大型,高需求的Web应用程序到Tomcat 5.5,并注意到一些特殊的减速行为似乎与JVM暂停有关。为了在Tomcat 4上运行我们的应用程序并支持随着时间的推移增加的负载,许多不那么标准的JVM参数按照下面的设置和调整,我希望有Tomcat JVM调优经验的人可以评论任何可能有害的东西到Tomcat 5.5安装。还要注意其中一些可以从以前版本的Java继承(我们在Java 1.6上运行Tomcat 4并且这些参数成功运行了一段时间,但是可能已经引入了一些来帮助Java 1.4上的垃圾收集,这是我们的Tomcat 4安装了很长时间,现在可能弊大于利。)
We have recently migrated a large, high demand web application to Tomcat 5.5 from Tomcat 4 and have noticed some peculiar slowdown behavior that appears to be related to JVM pauses. In order to run our application and support increased load over time on Tomcat 4, many not so standard JVM parameters were set and tuned as per the below, and I am hoping someone with Tomcat JVM tuning experience can comment on anything that would likely be detrimental to a Tomcat 5.5 install. Note also that some of these could be carry over from previous versions of Java (we were running Tomcat 4 on Java 1.6 with these parameters successfully for some time, but some may have been introduced to help garbage collection on Java 1.4 which was the basis of our Tomcat 4 install for a long time, and may now doing more harm than good).
一些注释:
- 应用程序内存占用量为1美元左右,可能略高于此。
- CPU不是问题 - 所有机器
为应用程序提供服务(负载平衡)是
< 30%CPU - 机器上物理内存的空间很大。
- -XX:MaxPermSize = 512m是唯一添加的参数作为5.5升级并对outofmemory permgen空间问题做出反应(它解决了)。
- 在Java 1.6上运行,Solaris OS
- Application memory footprint isaround 1GB, probably slightly over.
- CPU is not an issue - all machines serving the app (load balanced) are < 30% CPU
- Lots of headroom on physical memory on the machines.
- -XX:MaxPermSize=512m was the only parameter added as part of the 5.5 upgrade and was reactive to an outofmemory permgen space issue (which it solved).
- Running on Java 1.6, Solaris OS
-server -Xms1280m -Xmx1280m -XX:MaxPermSize = 512m -XX:ParallelGCThreads = 20 -XX:+ UseConcMarkSweepGC -XX:+ UseParNewGC -XX:SurvivorRatio = 8 -XX:TargetSurvivorRatio = 75 -XX :MaxTenuringThreshold = 0 -XX:+ AggressiveOpts -XX:+ PrintGCDetails -XX:+ PrintGCTimeStamps -XX:-TraceClassUnloading -Dsun.io.useCanonCaches = false -Dsun.net.client.defaultConnectTimeout = 60000 -Dsun.net.client.defaultReadTimeout = 60000
-server -Xms1280m -Xmx1280m -XX:MaxPermSize=512m -XX:ParallelGCThreads=20 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:SurvivorRatio=8 -XX:TargetSurvivorRatio=75 -XX:MaxTenuringThreshold=0 -XX:+AggressiveOpts -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:-TraceClassUnloading -Dsun.io.useCanonCaches=false -Dsun.net.client.defaultConnectTimeout=60000 -Dsun.net.client.defaultReadTimeout=60000
推荐答案
其中一位Java冠军,Kirk Pepperdine的博客:。
引用1
GC文档会告诉你设置会产生什么影响,但通常不知道效果会是什么。你在路上走错路的最大线索就是当你显式设置一个值,然后给出GC人体工程学的提示。另一个线索是,如果你没有合理的理由调整设置。并且只是因为一些所谓的专家说这个设置效果最好的只是噪音,而不是声音和certanly不是理由。
One of the Java Champions, Kirk Pepperdine's blog : http://kirk.blog-city.com/how_to_cripple_gc_ergonomics.htm.
Quote 1"GC documentation will tell you what the setting affects but often without telling what the effect will be. The biggest clue that you've taken the wrong fork in the road is when you explicitly set a value and then give a hint to GC ergonomics. Another clue is if you don't have a sound reason to adjust a setting. And just because some so called expert says this setting works best is only noise, not sound and certanly not a reason."
引用2
正如我在一篇热门博客文章中所述,除非你有一个非常好的,否则不要触摸旋钮这样做的原因。如果你必须触摸旋钮,只需使用那些有助于人机工程学的设备,而不是那些能够降低人体工程学能力以满足你的暂停时间和吞吐量目标的设备。
Quote 2"As I've stated in a prevous blog entry , don't touch the knobs unless you have a very good reason to do so. If you must touch the knobs, tred lightly by only using those that help ergonomics and not those that pin things down crippling ergonomics ability to meet your pause time and throughput goals."
所以,我建议你回到原点
-server -Xms1280m -Xmx1280m -XX:MaxPermSize = 512m -XX:+ UseConcMarkSweepGC -XX:+ PrintGCDetails -XX:+ PrintGCTimeStamps -XX:-Trace ClassUnloading -Dsun.io.useCanonCaches = false -Dsun.net.client.defaultConnectTimeout = 60000 -Dsun.net.client.defaultReadTimeout = 60000
So, I would suggest that you go back to plain
-server -Xms1280m -Xmx1280m -XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:-TraceClassUnloading -Dsun.io.useCanonCaches=false -Dsun.net.client.defaultConnectTimeout=60000 -Dsun.net.client.defaultReadTimeout=60000
查找是否能让您更好性能。如果是,坚持下去
BTW,-XX:MaxPermSize = 378m有什么问题吗?
Java 1.6的人体工程学设计比1.4更好。您可能希望将其调整为小于1.4
BTW,您是否尝试过Tomcat 6? Tomcat 6在Java 6上运行得比Tomcat 5.5好得多。
Find if that gives you better performance. If yes, stick to it
BTW, did -XX:MaxPermSize=378m have any issues ?
Java 1.6 has much better ergonomics than 1.4. You might want to tune it less than 1.4
BTW, did you try Tomcat 6 ? Tomcat 6 runs much better on Java 6 than Tomcat 5.5.
PS:我现在已经使用Tomcat一段时间了,并且通常尝试免费提供sun的JDK在这里和那里进行一点点调整。
P.S : I've been using Tomcat for a while now and usually try to give sun's JDK free reign with little tuning here and there.
这篇关于适当的Tomcat 5.5启动参数可以调整JVM以满足极高需求的大型堆Web应用程序的需求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!