0

Using RabbitMQ and Spring AMQP I have a Java application containing some @RabbitListeners. 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).

My question is regarding the approach. First of all, I'm not an expert in the Java memory model. 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. 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. 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)?

Zeruno
  • 1,391
  • 2
  • 20
  • 39

1 Answers1

1

The size of the heap and allocation rate defines how/when the GC will run. Start with a small heap size of around 256MB. Just run your test for at least 15 minutes because there are different type of garbage collection phases.

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.

There is a lot you can do to tune the behavior of the GC to achieve desired performance characteristics. https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/

Johnny V
  • 795
  • 5
  • 14
  • Thanks for your answer. Would you be familiar with a very detailed reference regarding the JVM Garbage Collector defaults? – Zeruno Feb 26 '19 at 10:17
  • In particular, I am interested to know if there are any parameters that depend on the state of the machine at the moment (beyond physical details) such as currently free memory. I want to know if it's safe to run two tests against each other using the default garbage collector. – Zeruno Feb 26 '19 at 11:14
  • It depends on which GC you have enabled and what version of Java you have. Generational GC will collect from a Young Generation when full and Old Generation when full. Occupancy variables deal with the thresholds which GC occurs. See the Ergonomics section of the documentation I linked to. All conditions are internal to that JVM, running two JVM won't change anything unless you are trying to allocate more memory than the system has. – Johnny V Feb 26 '19 at 16:32
  • So if I run two JVM with same Java version and without any configuration, my two GCs should be configured in the same, default, way? – Zeruno Feb 26 '19 at 17:05
  • Yes, then they will be identical. https://stackoverflow.com/questions/28272923/default-xmxsize-in-java-8 – Johnny V Feb 26 '19 at 17:09
  • Thanks for your answer, this is pretty much what I'm looking for. – Zeruno Feb 26 '19 at 17:48