Recently, I've got a chance to investigate "the memory utilization of xvm server"

On a X4450 system, I installed SXCE 86 OS and installed 32 Windows XP guest OSs by zfs cloning.

  • System : SunFire X4450
  • CPU : Intel(R) Xeon(R) CPU 2.40GHz QuadCore 4 CPU
  • Memory : DDR2 4GB x 4, Total 16GB
  • DISKS : SAS 146GB x 3, 1 for root file system, 2 for zfs storage pool
  • OS : Solaris Express Community Edition snv_86 X86

- System Spec -

I created one Windows XP guest as a master os image and cloned it to 32 guests. After creating them, I've started guests one by one. As I increase the number of running guests, I monitored memory utilization of system by 'echo "::memstat" | mdb -k' command and got results below. The results shows physical memory status not virtual and Kernel, Free(freelist), Balloon memories are significant values who vary as the number of running guests changes. 'Balloon' is a memory assigned to hypervisor to be used for guest os.


Page Summary                Pages                MB  %Tot
------------     ----------------  ----------------  ----
Kernel                     207152               809    5%
Anon                        19702                76    0%
Exec and libs                5067                19    0%
Page cache                   9422                36    0%
Free (cachelist)            12011                46    0%
Free (freelist)           3846103             15023   94%
Balloon                         0                 0    0%

Total                     4099457             16013 

- memory status -

26 was the maximum number I could run. As I try to run another guest, I encountered this error message.

-bash-3.2# xm start winxp27

Error: Not enough memory is available, and dom0 cannot be shrunk any further
Usage: xm start <DomainName>

Start a Xend managed domain
  -p, --paused                   Do not unpause domain after starting it
  -c, --console_autoconnect      Connect to the console after the domain is created

- Error message -

Since zfs is major memory consumer of kernel, I limited zfs_arc_max to 512MB.

-bash-3.2#vi /etc/system
......
set zfs:zfs_arc_max=0x20000000
...... 

Increasing the number of running guests by 26, I could get this graph.


The graph shows some simple phenomenons.

  • The xVM Server assigns physical memory for guest os not virtual memory.
  • Balloon memory seems come from Free memory. They are in inverse proportion.
  • To add guest OS, available Free memory, larger than the memory to be assigned to guest, must exists.
  • Running guest OS requires not only Balloon memory for guest but also Kernel memory for hosts. Required Kernel memory is estimated about 250MB per a guest.
  • In case of running large number of guests(>17 guests), Kernel memory does not grow any more and decrease its size as the number of running guests grows.
  • Though Kernel memory decreases, free memory keeps its size (17~21 guests).
  • Kernel memory & Free memory shrinks together over 21 guests.

Before the test, I had no idea about the increase of Kernel memory.  However, in fact, running guest os requires not only Balloon memory but also additional Kernel memory in the host. And the maximum number of runnable guests depends on the available Free memory on the system. In case of lack of Free memory, running additional guests is not possible. Those are the conclusion of my test.

Anyway the results are very interesting as the number of guests goes over 17. The Kernel memory does not increase, even it shrinks though Free memory is still enough. Between 18~21, Kernel memory decreases instead of Free memory, and then Free memory & Kernel memory decrease together over 21.

In general, the kernel will not free any memory it allocates for itself, but it also wants to keep a certain amount free for application usage. When the amount of free memory drops below a certain threshold, it will begin to free its own memory.  As more memory is used beyond this point, both the kernel memory and free memory will decrease, although the rate of decrease for each will be unpredictable.1)

I went further. I started shutting down guests one by one, then, I could get this graph.

Simple but interesting result. There were no changes in memory status at all. xVM guest OS do not return the memory after shutting down. I thought this is a bug at first, however, it is a correct operation. When a domU is shut down, the memory should remain free to allow quicker creation of future domUs.2)

I would like to get comments from you, experts.. :)


* 1), 2) by Ryan Scott in SW Eng group

Comments:

I would suggest testing without balloon memory turned on, and just assigning each XP box 512MB RAM. Then see how many you can start.

The issue is that balloon memory remains allocated and many memory tools do not interpret what is going on properly. See http://wiki.xensource.com/xenwiki/XenFaq#head-ff507535c38a3191053dad83d8d68d19c5482e70 for a Xen-based answer.

Posted by patrick giagnocavo on 6월 30, 2008 at 03:20 오후 KST #

How big is the allocation for each of your VMs? I don't think these figures make any sense. Also, you're making unwarranted assertions about kernel memory usage (and a number of other things).

Posted by John Levon on 7월 02, 2008 at 06:55 오전 KST #

Post a Comment:
Comments are closed for this entry.

This blog copyright 2009 by Sangpill Kim