简体   繁体   English

内存监视包含RabbitMQ侦听器的应用程序的Java堆大小使用情况

[英]Memory monitoring Java heap size usage of application containing RabbitMQ listener

Using RabbitMQ and Spring AMQP I have a Java application containing some @RabbitListener s. 使用RabbitMQ和Spring AMQP,我有一个Java应用程序,其中包含一些@RabbitListener These consumers listen to a queue and process messages very quickly. 这些使用者收听队列并非常快速地处理消息。 I am interested to know the memory behaviour of this application over time (I will supply a load test via some tool such as JMeter). 我很想知道此应用程序随时间的内存行为(我将通过诸如JMeter之类的工具提供负载测试)。

My question is regarding the approach. 我的问题是关于方法。 First of all, I'm not an expert in the Java memory model. 首先,我不是Java内存模型的专家。 In my understanding, I have to refer to the used Java heap memory to see how much memory that processing messages consumes in my application over time. 以我的理解,我必须参考使用的Java堆内存,以查看随着时间的推移,处理消息在我的应用程序中消耗了多少内存。 Is this correct? 这个对吗? Are there other relevant metrics? 还有其他相关指标吗?

Secondly, because of the Java garbage collector, there will be some delay before the garbage collector kicks in and does its job, freeing memory and updating the used memory heap. 其次,由于Java垃圾收集器,在垃圾收集器启动并执行其工作,释放内存和更新已使用的内存堆之前,会有一些延迟。 If I run a short test, such as a test lasting less than a minute, what guarantees do I have that the garbage collector will kick in frequently enough that I can see a result of varying memory size (I do not want to see constant memory over time)? 如果我运行一个简短的测试,例如持续不到一分钟的测试,那么我可以保证垃圾收集器会足够频繁地启动,以至于我可以看到内存大小变化的结果(我不想看到恒定的内存)随着时间的推移)?

The size of the heap and allocation rate defines how/when the GC will run. 堆的大小和分配率定义了GC运行的方式/时间。 Start with a small heap size of around 256MB. 从大约256MB的小堆大小开始。 Just run your test for at least 15 minutes because there are different type of garbage collection phases. 只需运行测试至少15分钟,因为存在不同类型的垃圾收集阶段。

https://blog.codecentric.de/en/2014/01/useful-jvm-flags-part-8-gc-logging/ https://blog.codecentric.de/en/2014/01/useful-jvm-flags-part-8-gc-logging/

You'll want to enable the GC log and load it into https://gceasy.io/ for analysis. 您需要启用GC日志并将其加载到https://gceasy.io/中进行分析。

There is a lot you can do to tune the behavior of the GC to achieve desired performance characteristics. 您可以做很多事情来调整GC的行为以获得所需的性能特征。 https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/ https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/

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

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