为什么这些Tomcat服务器的JVM每小时执行一次完整的GC? [英] Why does the JVM of these Tomcat servers perform a full GC hourly?

查看:443
本文介绍了为什么这些Tomcat服务器的JVM每小时执行一次完整的GC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们运行了很多Tomcat服务器,并且观察到完整垃圾回收(GC)通常每小时执行一次,特别是当内存使用率相对较低时。准确的时间似乎与应用程序服务器启动的时间有关;如果服务器在01:13启动,完整的GC在02:13完成,下一个完整的GC将在03:13完成。我无法找到任何文档来解释这种行为。



这是一个问题,因为同时启动的服务器池都倾向于在完全相同的情况下执行完整的GC时间。如果GC延迟时间足以导致负载平衡器将服务器标记为关闭,则整个应用程序可以在一段时间内脱机。如果完整的GC可以在一段时间内分发,这样会更好,因此没有两台服务器同时进行完整的GC,但我找不到任何方法来控制此行为。



有没有其他人看到过这种行为?有没有什么方法可以影响这些常规完整GC发生的时间? 这个已知的bug JreMemoryLeakPreventionListener会导致完整的GC每小时当gcDaemonProtection = true



确认您的Tomcat版本和 gcDaemonProtection 您的 JreMemoryLeakPreventionListener (默认为 true )。



补丁据称包含在Tomcat v.7.0.28 +和v.6.0.36 +中。



无论是升级服务器还是选择非易失性存储器,升级解决方案 here ,总结如下:


  1. 抑制满使用JVM的垃圾收集arg -XX:+ DisableExplicitGC

  2. 保留完整的GC,但要遵循JVM arg
    -XX:+ ExplicitGCInvokesConcurrent

  3. set < Listener className =org.apache.catalina。 core.JreMemoryLeakPreventionListener
    gcDaemonProtection =false/>

  4. 禁用侦听器

信用到期的信用;我从此处获得了我的初步答案。


We run many Tomcat servers and have observed full garbage collections (GCs) are often performed on an hourly basis, particularly when memory usage is relatively low. The precise time appears to be relative to the time the application server was started; if a server is started at 01:13, a full GC is done at 02:13, and the next full GC will occur at 03:13. I haven't been able to find any documentation to explain this behavior.

This is a problem because a server pool started simultaneously all tend to do full GCs at around the same time. If the GC delay is long enough to cause a load-balancer to mark a server as down, the entire application can go offline for a time. It would be better if the full GCs could be distributed across a period so no two servers are doing a full GC at the same time, but I can't find any way to control this behavior.

Has anyone else seen this behavior? Is there any way to influence when these "regular" full GCs happen?

解决方案

Your "regular" hourly GCs are probably due to this known bug, "The JreMemoryLeakPreventionListener causes a full GC every hour when gcDaemonProtection=true".

Confirm your Tomcat versions and the value of the gcDaemonProtection property of your JreMemoryLeakPreventionListener (default is true).

The patch was purportedly included in Tomcat v.7.0.28+ and v.6.0.36+.

Either upgrade your server(s), or choose a non-upgrading solution from here, summarized as:

  1. suppress full garbage collections using JVM arg -XX:+DisableExplicitGC
  2. keep the full GCs, but defer to the CMS collector using JVM arg -XX:+ExplicitGCInvokesConcurrent
  3. set <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" gcDaemonProtection="false"/>
  4. Disable the listener

Credit where credit is due; I obtained my initial answer from here.

这篇关于为什么这些Tomcat服务器的JVM每小时执行一次完整的GC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆