Rob
Rob

Reputation: 5622

JVM heap sizing in VMware guests

This question is probably better phrased: how does running a Java server on a hypervisor such as VMware ESX affect the Java heap?

The conventional wisdom for Java server applications is that performance is best if you allocate all the heap at JVM startup, rather than allowing the heap to be dynamically resized as the need arises. In other words, if you set the heap size to 1GB, your Java process will grab 1GB of contiguous virtual address space (+ whatever is needed for the binaries), memory which is no longer available to other applications.

Is VMware smart enough to detect that some of this heap is in fact unused? How does this affect GC performance? Would it be better to let the heap be dynamically resized in VMware? What GC strategies work best with VMware guests?

Also, would anyone point me towards guidelines for tuning JVM heaps in virtualized environments?

Upvotes: 7

Views: 6317

Answers (2)

Senior Systems Engineer
Senior Systems Engineer

Reputation: 1153

In this case, make sure that Reservation = OS vRAM + JVM + heap size.

Meanwhile, the following are general recommendations from VMware KB site:

Size the virtual machine memory to leave adequate space for the Java heap, the other memory demands of the Java virtual machine code and stack, and any other concurrently executing process that needs memory from the guest operating system.

Set the memory reservation value in the VMware Infrastructure Client to the size of memory for the virtual machine. As any type of Memory Swapping (physical or virtual) is detrimental to performance of JVM heap especially for Garbage Collection.

Determine the optimal number of virtual CPUs for a virtual machine that hosts a Java application by testing the virtual machine configured with different numbers of virtual CPUs at different times with the same load.

If you are using multiple Garbage Collector threads in your JVM, match the number of those threads to the number of virtual CPUs that are configured in the virtual machine.

For easier monitoring and load balancing, use one JVM process per virtual machine.

If your ESX Server is overcommitted, ensure the the Balloon Driver is running within the virtual machine so that memory is optimally managed.

Upvotes: 2

Rob
Rob

Reputation: 5622

Related to my question:

Here is a PDF that provides a broad overview of considerations for running Java on VMware guests: link text

Upvotes: 5

Related Questions