A couple of days ago we finally got out one of my favorite papers from our ongoing vSphere launch activities.  This paper on ESX memory management, written by Fei Guo in performance engineering, has three graphs that are absolute gems.  These graphs show balloon driver memory savings next to throughput numbers for three common benchmarks.  The conclusion is inescapable: the balloon driver reclaims memory from over-provisioned VMs with virtually no impact to performance.  This is true on every workload save one: Java.


Example 1: Kernel Compile

Linux kernel compilation models a common developer environment involving a large number of code compiles.  This process is CPU and IO intensive but uses very little memory.




Results of two experiments are shown on this graph: in one memory is reclaimed only through ballooning and in the other memory is reclaimed only through host swapping.  The bars show the amount of memory reclaimed by ESX and the line shows the workload performance.  The steadily falling green line reveals a predictable deterioration of performance due to host swapping.  The red line demonstrates that as the balloon driver inflates, kernel compile performance is unchanged.


Kernel compilation performance remains high with ballooning because this workload needs very little memory and the guest OS can easily take unused pages from the application.  Performance falls with swapping because ESX randomly selects virtual machine pages for swapping, whether those pages are in use by the application or not.  The guest OS is better at selecting pages for reclamation than ESX is.


Example 2: Oracle/Swingbench

Oracle's database is best tested against Swingbench, the OLTP load generation tool provided by Oracle.  Database workloads utilize all system resources but show a non-linear dependence on memory.  Memory can be safely reclaimed from OSes running databases until the cache becomes smaller than needed by the workload.  The following figure shows this.




As before, the virtual machine using only ballooning maintains higher performance under memory pressure than the virtual machine whose memory is being swapped away by the host.  Performance is constant and shows no negative impact due to ballooning until the balloon encroaches on the SGA.  Again, ESX's host swapping randomly selects pages to send to disk which degrades performance even at small swap amounts.


As with kernel compile, the balloon driver safely reclaims memory from over-provisioned VMs with little impact to application performance.


Example 3: Java/SPECjbb

Java provides a special challenge in virtual environments due to the JVM's introduction of a third level of memory management.  The balloon driver draws memory from the virtual machine without impacting throughput because the guest OS efficiently claims pages that its processes are not using.  But in the case of Java, the guest OS is unaware of how the JVM is using memory and is forced to select memory pages an arbitrarily and inefficiently as ESX's swap routine.




Neither ESX nor the guest OS can efficiently take memory from the JVM without significantly degrading performance.  Memory in Java is managed internal to the JVM and efforts by the host or guest to remove pages will equally negatively impact Java applications performance.  In these environments it is wise to manually set the JVM's heap size and specify memory reservations for the virtual machine in ESX to account for the JVM, OS, and heap.


Conclusions and Scott's Special Recommendation

Love your balloon driver.  Your application owners are always asking for more memory than they need.  With great comfort you can over-provision memory some and rely on ESX and the balloon driver to reclaim what is not in use.  Without the balloon driver, ESX will be forced to use its last technology for managing memory over-commit: host swapping.  And host swapping always decreases performance.


So here is my special recommendation for you: never, ever disable the balloon driver.  This forces the host to swap that virtual machine's memory, should that resource become scarce.  And where ballooning usually will not hurt performance, swapping always will.  If you must protect an application from memory reclamation due to memory over-commitment, use reservations.  They make admission control more effective, they self-document the needs of the VM, and they are easily configured.