JVM性能调优

OptionDetails
-XX:+UseConcMarkSweepGCSets the garbage collector policy to the concurrent (low pause time) garbage collector (also known as CMS)设置垃圾收集器并发政策(低暂态时间),垃圾收集器(也被称为CMS)
-XX:+CMSIncrementalModeEnables the incremental mode. (works only with -XX:+UseConcMarkSweepGC)启动增量模式(只作用于 -XX:+UseConcMarkSweepGC)
-XX:+CMSIncrementalPacingEnables automatic adjustment of the incremental mode duty cycle based on statistics collected while the JVM is running 当JVM在运行时,依据收集的统计信息启用增量模式自动调节占空比
-XX:CMSIncrementalDutyCycleMinThe percentage (0-100) which is the lower bound on the duty cycle when CMSIncrementalPacing is enabled 启动CMSIncrementalPacing占空比的最小值
-XX:CMSIncrementalDutyCycleThe percentage (0-100) of time between minor collections that the concurrent collector is allowed to run. If CMSIncrementalPacing is enabled, then this is just the initial value.
-XX:ParallelGCThreadsSets the number of garbage collector threads设置垃圾收集器的线程数
-XX:+UseParNewGCEnables multi threaded young generation collection.启动多线程收集器
-XX:MaxGCPauseMillisA hint to the throughput collector that it’s desirable that the maximum pause time is lowed than the given value. (n.b. it looks like this value can also be used with the CMS garbage collector)
-XX:GCTimeRatioA hint to the virtual machine that it’s desirable that not more than 1 / (1 + GCTimeRation) of the application execution time be spent in the collector
-XX:+DisableExplicitGC

Disables explicit garbage collection calls (System.gc())

 

 

标准的JVM是配置为了高吞吐量,吞吐量是为了科学计算和后台运行使用,而互联网商业应用,更多是为追求更短的响应时间,更低的延迟Latency(说白了就是更快速度),文章延迟到处存在,它会降低你的销售,用户打开网页没有快速响应,调马走人,亚马逊发现每100毫秒的延迟会损失1%的销售量。

而垃圾回收机制一旦启动就引发系统暂停,导致用户请求后的响应时间延长,通常的JVM配置参数如下:


-Xms2g -Xmx2g -Xmn150m
-XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode
-XX:+CMSIncrementalPacing -XX:CMSIncrementalDutyCycleMin=10
-XX:CMSIncrementalDutyCycle=50 -XX:ParallelGCThreads=8
-XX:+UseParNewGC -XX:MaxGCPauseMillis=2000
-XX:GCTimeRatio=10 -XX:+DisableExplicitGC


作者发现使用-XX:+UseConcMarkSweepGC有性能上百分之40的降低,而网络上各种JVM调试都推荐此配置。

使用下面配置,比UseConcMarkSweepGC 有百分之20的性能提升,且暂停时间在100微秒以下(10K 100线程)

-Xms2g -Xmx2g -Xmn150m
-XX:GCTimeRatio=2 -XX:ParallelGCThreads=8
-XX:+UseParNewGC -XX:MaxGCPauseMillis=2000
-XX:+DisableExplicitGC

垃圾回收机制
Advanced JVM Tuning for Low Pause | mindstorms


辅助作者观点的另外一篇实战案例JVM配置也是如上,该案例中几乎使用了Oracle的内存数据库,但是还是有问题,使用类似上述配置后得到性能提升:
http://www.tikalk.com/java/performance-tunning-case-study


XX:PermSize=512m -Xms5g -Xmx5g -XX:NewSize=756m -XX:MaxNewSize=756m -XX:SurvivorRatio=6 -XX:GCTimeRatio=2 -XX:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值