Many of our customers have run critical enterprise Java applications on vSphere successfully. The best practices guide is often referred to by our customers when embarking on running Java applications on vSphere.
December last year version 2 of the best practices paper was released here: http://www.vmware.com/resources/techresources/1087,
The paper covers quite few best practices and definitely recommended for anyone doing deployments of Java applications on vSphere, however it is worthwhile to note that the top 3 most sought after best practices from this paper are as follows and based on customer interaction:
- BP4 – VM Memory Sizing
- BP5 – Setting Memory Reservation
- BP6 – Using memory large pages
BP4 – VM memory Sizing: Whether you are using Windows or Linux as your guest OS, refer to the technical specification of the various vendors for memory requirements. It is common to see the guest OS allocated about 1GB in addition to the JVM memory size. However, each installation may have additional processes running on it, for example monitoring agents, and you need to accommodate their memory requirements as well. Figure 2 shows the various segments of JVM and VM memory, and the formula summarizes VM Memory as:
VM Memory (needed) = guest OS memory + JVM Memory,
whereJVM Memory = JVM Max Heap (-Xmx value) + Perm Gen (-XX:MaxPermSize) + NumberOfConcurrentThreads * (-Xss)
The -Xmx value is the value that you found during load testing for your application on physical servers. This value does not need to change when moving to a virtualized environment. Load testing your application when deployed on vSphere will help confirm the best –Xmx value. It is recommended that you do not overcommit memory because the JVM memory is an active space where objects are constantly being created and garbage collected. Such an active memory space requires its memory to be available all the time. If you overcommit memory ballooning or swapping may occur and impede performance. ESX host employs two distinct techniques for dynamically expanding or contracting the amount of memory allocated to virtual machines. The first method is known as memory balloon driver (vmmemctl). This is loaded from the VMware Tools package into the guest operating system running in a virtual machine. The second method involves paging from a virtual machine to a server swap file, without any involvement by the guest operating system.
BP5- Setting Memory Reservation: JVMs running on VMs have an active heap space requirement that must always be present in physical memory. Use the VMware vSphere Client to set the reservation equal to the needed VM memory.
Reservation Memory = VM Memory = guest OS Memory + JVM Memory
You may set this reservation to the active memory being used by the VM for a more efficient use of the amount of memory available. Or, a simpler approach is to set the reservation equal to the total configured memory of the VM.
BP6- Use memory large Pages: Large memory pages help performance by optimizing the use of the Translation Look-aside Buffer (TLB), where virtual to physical address translations are performed. Use large memory pages as supported by your JVM and your guest operating system. The operating system and the JVM must be informed that you want to use large memory pages, as is the case when using large pages in physical systems.
- Set the -XX:+UseLargePagesat the JVM level for Sun HotSpot.
- On the IBM JVM it is -Xlp, and JRockit -XXlargePages.
- You also need to enable this at the guest OS level. For information, see Large Page Performance: ESX Server 3.5 and ESX Server 3i v3.5.