VMworld 2011 Session BCA1230 – Best practices for virtualizing Java

This is a live update from VMworld! These are just my notes during the session, please forgive the grammatical errors, I am sure I missed parts of the lecture as I am taking notes…

Be sure to check out the actual session recording at http://www.VMworld.com – search for the session using the session identifier in my blog post title.

Top 2 Best Practices

1. Take care of memory! VM memory, ESX, Java Geap
2. Virtual CPU Physical CPU, threads

Others discussed in:

http://www.VMWare.com/resources/tech resources/1087

Memory considerations:

Java Heap is the most sensitive area in the Java world- it must be in physical memory at all times, it mustn’t be swapped or ballooned ( either by the guest or by the host).

Memory mgt. In the Java Heap- Overview
– memory allocation rate dictates how fast objects are created
– objects are born in the ‘Eden Area’ (nursery), garbage collection to clear objects no longer needed
– rate at which you survive dictated by runtime flag to determine how many garbage collections they will survive
– If they survive, they are migrated to the ‘tenure area’
– garbage collection events should not be happening frequently, if so that means Object creation might be outstripping garbage scavenge events
– space made available in the Tenured Object Area due to clean up and compaction due to garbage collection
– programmers often over allocate heap space to prevent the heap from filling up, though this should not be necessary

Guest virtual memory is mapped to guest virtual memory, which is then mapped to physical memory. Extended page tables (Intel) ensures this physical mapping occurs in the hardware, rather than in the ESX kernel. get onto the latest hardware to ensure this happens (Nehalem or later).

ESX will enforce transparent page sharing to implement SIS of memory pages, but don’t over allocate RAM! It will put you in a position where the memory might get swapped ( Tomcat is ok for this, though- more on this later).

Use large pages in the JVM (there is a switch) and in the ESX if possible… This will effectively turn off TPS due to the larger pages.

ESX ballooning should be turned on, but not active. Ballooning is a great tool to ensure idle memory blahblahblah…

Summary of memory practices:
1- size the vm memory for sufficient space for the java heap, for other java operations (stack), other operations in the guest vm(monitoring etc), and to prevent swapping
2- set a memory reservation on the vm to the size of the ACTIVE memory at least (if in doubt, set the reservation to the configured size)
3- use large memory pages
4- use DRS to balance memory requirements across the cluster

NEW!!! vFabric Elastic Memory for Java (EM4J)
ships with TC Server, runs only with vSphere 5 and vFabric5
runs inside the JVM, new type of Java specific balloon driver (turn off the standard balloon driver)
Seen 20-30 percent overallocation of RAM with no performance impact

CPU Best Practices

For testing purposes, use 2 vCPU, for production, use as few vCPU as necessary. VMware has found in testing that it is rare to have more than a half dozen threads actually waiting for execution at any time.

How to determine the right number of vCPU? Through testing… The smallest number of vCPU that will provide the correct SLA… 2 is a good starting place, and 4 is the next best starting place. Fewer vCPU ensures better scaling.

In one case, if the programmer is using -Xgcthreads4 (the programmer is requiring 4threads), you will need 4 vCPU. Otherwise, TEST!

Of course, you should also monitor and design your infrastructure for best practices in the other areas:
– disk and network I/O
– timekeeping
– monitoring and management
– get on the latest hardware
– get on the latest version of vSphere

check out the forthcoming book:
“Enterprise Java Application Architecture on VMware vSphere”

– Posted using BlogPress…

Location:Winnick Ave,Las Vegas,United States

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s