A closer look at the new "Dynamic Memory" feature of Hyper-V: is it worth it for VDI? - Guest Bloggers - BrianMadden.com
Brian Madden Logo
Your independent source for desktop virtualization, consumerization, and enterprise mobility management.
Guest Bloggers's Blog

Past Articles

A closer look at the new "Dynamic Memory" feature of Hyper-V: is it worth it for VDI?

Written on Jan 27 2011 26,250 views, 23 comments


by Michel Roth

Microsoft Windows Server 2008 R2 Service Pack 1 will introduce two major new features: RemoteFX and Dynamic Memory. I've written about RemoteFX before (as has Brian), so today's focus is Dynamic Memory (from the VDI perspective). We'll also look at the inevitable question of how it compares to the memory management technologies in VMware ESX.

What is Dynamic Memory?

Dynamic Memory is a new feature of Microsoft Windows Server 2008 R2 Service Pack 1, or more specifically Hyper-V in Microsoft Windows Server 2008 R2 SP1. It lets you to take all of the memory in that Hyper-V host and dynamically distribute it across all of the VMs. (Hence the name "Dynamic Memory" -- possibly the first time a Microsoft feature name actually makes sense!) Dynamic Memory changes the way Hyper-V manages memory and makes it closer to the way CPU resources are managed, namely, shared across all VMs on the host. While I wish Dynamic Memory was as exactly as "dynamic" as CPU, we aren't quite there yet. In reality, the Dynamic Memory feature basically automates hot adding and removal of memory to a guest VM. (Super virtualization geeks might remember that the hot adding of memory in Hyper-V was actually planned for the first release back in 2007 but never made it.)

How does Hyper-V Dynamic Memory work?

The best non-technical way describe how Dynamic Memory works is to say that Hyper-V will give the guest VMs the right amount of RAM based on their actual usage. Of course there's a little bit more to it than that. Dynamic Memory works with the ‘driver enlightened’ architecture of Hyper-V. On the Hyper-v host, the Virtual Service Provider (VSP) manages the allocation of physical memory resources between the various virtual machines running on the host. Inside the enlightened guest, the Virtual Service Consumer (VSC) collects the information to determine virtual machine’s memory needs and executes necessary operations to add or remove memory.

Sounds cool right? Just "enable" it and be done? Unfortunately like I said, we're not quite there yet. You still need to configure some other parameters. Take a look at this screenshot:

Specifically, there are these 4 Dynamic Memory parameters:

  1. Startup RAM is the amount of RAM that Hyper-V will always give the host. Microsoft recommends that this is set to the minimum RAM system requirements of the guest OS.
  2. Maximum RAM is the upper limit of how much RAM the guest can grow to. This defaults to, and has a max value of, 64GB
  3. Memory buffer is slightly more complicated. It's the amount of extra memory that's reserved for the guest in addition to the committed memory that the guest VM is asking of Hyper-V. Think of it like the desired "extra" memory for that guest.
  4. Memory weight allows you to specify the importance of a VM in actual RAM allocation. The higher the memory weight, the higher the likelihood that VM will indeed get that memory. Memory weight will only kick in when the host is almost out of RAM.

Is Hyper-V Dynamic Memory any good for VDI?

Definitely! I love it.

I'll qualify by saying that I'm a ‘desktop virtualization guy,’ not a ‘server virtualization guy.’ (In this case that's a very good thing.) Let me explain: Desktop virtualization was hard enough when it was just Terminal Server, and the addition of VDI meant that things haven’t got any easier. If anything, it's made desktop virtualization harder. My personal opinion that VDI should be a lot easier and there are many steps that can be taken to achieve that, and making sure you use the RAM on your host as efficiently as possible is a great example of that which the Dynamic Memory feature gives you.

But while Dynamic Memory simplifies memory assignments, it creates new questions to answer like What should the memory buffer be? or How important is this VM? which are not that simple to answer. This is the part where it's great to be a ‘desktop virtualization guy’ because for VDI you shouldn’t care! :) There should be no reason why you'd need to change the memory buffer or the memory weight in a VDI environment. You can even keep the Maximum RAM left at its default (64GB) in most cases. So knowing that, Dynamic Memory comes really close to fulfilling the goal of memory being a completely shared and transparent resource like CPU.

That said, it may be worth experimenting with various Dynamic Memory configurations for your VDI environment. For example, you could provide Windows 7 virtual desktops with the minimum required memory (or even less!) to really put Dynamic Memory to work. You can also consider setting the ‘Maximum RAM’ to a lower limit: 2GB for example. This could possibly improve VM density since it limits the impact of VMs that eat up heaps of memory (for either good or bad reasons). Either way, make sure you watch the “Available Memory” performance counter in “Hyper-V Dynamic Memory Balancer” on the R2 SP1 Hyper-V host to make sure that you don’t overcommit memory on your host or else performance will plummet when you start paging too much. Some paging can be okay and safe (because the kernel is never paged out), but too much paging will definitely kill performance. Making the most of Dynamic Memory can really be worth your while. In fact Microsoft has seen improvements of up to 40% (!) in density for VDI workloads.

So it's all good?

It is for the most part. Without going into extreme detail on how Hyper-V assigns memory, it's important to know that Hyper-V talks to the guest OS to find out how much memory it actually needs and then allocates it as needed. Just be aware that if you run apps in your guest that query the OS for the amount of memory available on launch or use product installers that check the amount of memory before the install starts, these might cause a problem because sometimes they won’t continue when they ‘determine’ there's too little RAM available.

The reason for this is that Hyper-V allocates the extra memory when it's actually being requested by the OS, not when some random application queries from within the guest for the available memory. So if you do run into that situation, you'll need to set the minimum memory parameters of the guest to match the memory requirements of the product installer. In practicality this shouldn't be a big deal biggie because you'll probably use a ‘golden image’ of sorts so that install will be a one-time thing anyway. The problem becomes larger when an application queries for a certain amount of memory at launch and fails to start correctly if it doesn't find what it's expecting. The only option you have in that case is to set the minimum memory parameters of the guest to match the memory requirements of that application (but at the expense of limiting the efficiency of Dynamic Memory).

Finally you might also run into some weirdness with apps that do their own memory management. Some apps will grab all the memory they can in order to get the best performance. While this might be fine on a single-use PC, it's not such a good idea on a Dynamic Memory-enabled guest. The best option for these scenarios is to lower the Maximum memory for that VM, but again, this limits the efficiency of Dynamic Memory.

And of course, the fine print leads to one big caveat

It's important to know that in order to use Dynamic Memory, you need to upgrade not just Hyper-V (to 2008 R2 SP1), but also the in-guest ‘integration components’ (which are what allow the guest OS to be able to use the Dynamic Memory feature.) Unfortunately Dynamic Memory will only work on these guest operating systems:

  • Windows Server 2008 R2
  • Windows Server 2008 (SP2)
  • Windows Server 2003 R2
  • Windows Server 2003 (SP2)
  • Windows 7 (Enterprise and Ultimate only)
  • Windows Vista (Enterprise and Ultimate only)

That’s right. No Windows XP! And only the Enterprise and Ultimate Editions of Windows 7! (Although it really isn't that bad because you need the Enterprise or Ultimate Edition of Windows 7 to be able to do VDI anyway.)

Doesn't VMware ESX have this as well?

Yes and no.

VMware ESX has memory management techniques of its own (and has had most of them for a long time now). The most important techniques (great doc here) are Idle Memory Tax (IMT), Second Level Paging (Hypervisor swapping) and Memory Compression (new in ESX 4.1). Instead of scrutinizing all the different technologies VMware uses and how these compare to Dynamic Memory, let’s have a look at the goal of both Microsoft and VMware with their techniques.

Both companies have the goal to maximize the RAM usage on the host which is exactly what's needed for VDI. The most important difference between VMware's and Microsoft's approach in my mind is that Dynamic Memory allocates memory on demand (in ‘real-time’) whereas VMware’s memory management techniques pre-allocate memory and then uses several memory management techniques to reclaim unused memory. With VMware it's also easier to oversubscribe the physical memory of the host (note how I didn't use the word overcommit!) and I think that's a risk in most current VDI deployments. No matter how you slice it or dice it, when RAM is oversubscribed it introduces a higher probability of paging. This in return means a huge increase in IOPS. I guess it should go without saying that this is something you should avoid at all costs in VDI environments.

So should I move my VDI environment to Hyper-V now?

It’s interesting to see how the same questions keep popping up. In the past, every time a new version of Terminal Server came out, people would ask Do I still need Citrix? This question about Hyper-V feels the same and the answer is also the same: it depends. It depends on what you need out of your hypervisor. From the VDI perspective you should want to maximize the usage of the RAM on your host to its guests in the most flexible and efficient way. That’s exactly what Hyper-V 2008 R2 SP1 gives you. But of course it's also in ESX today. I don’t think Dynamic Memory will be the reason for people to abandon ESX en masse. I do think that, looking at memory management from a VDI perspective, Hyper-V fits the bill just as well as ESX does, if not better.

 
 




Our Books


Comments

Daniel Feller wrote re: A closer look at the new "Dynamic Memory" feature of Hyper-V: is it worth it for VDI?
on Thu, Jan 27 2011 8:31 AM Link To This Comment

Michael, great article.  But I do have one concern.  Dynamic memory is great.  Most people only use a small percentage of their ram, but what I have noticed is that users slowly consume more and more ram throughout the day. For example, when you start, you usually only open ump one or two apps.  But by the end of the day, you typically have 8-10. And many browsers suck up the ram like crazy as the day progresses.  So by the end of the day, users are at their max a locations.

Now you say don't overcommitted. That is great advice.  So if I know I can safely grant 2 gb of ram for each desktop without overcommitting, then why would I need dynamic memory? How will it get me more density? If I add more desktops, I am now overcommitted. Why not simply use static memory and give everyone their 2gb from the start?

bjorn bats wrote re: A closer look at the new "Dynamic Memory" feature of Hyper-V: is it worth it for VDI?
on Thu, Jan 27 2011 9:49 AM Link To This Comment

Great article.

and a great start of discussion by daniel.

i think the reason not to make a reservation is the 2 gb is not always needed. Only at startup i believe if i look at microsoft oses.

but yes i we don't overcommit what will be the benefit. The benefit is still somehow there like the tps feature in esx.

the bad thing of giving a maximum is that when the os needs more than the maximum its starting to swap.

i always try to prevent settings maximums and limits so that i have really a dynamic usage of my memory.

VMGuy wrote re: A closer look at the new "Dynamic Memory" feature of Hyper-V: is it worth it for VDI?
on Thu, Jan 27 2011 3:59 PM Link To This Comment

DM is hot add plus a copy of VMware ballooning mechanism.

The only real difference between DM and VMware memory techniques is the hotadd part.  ESX adds TPS and memory compression on top of that.

I cannot see how DM can be better. ESX can remove and give back memory as needed to the VM using the ballooning driver, and do it automatically, without the need to set any parameter.

On top of that, TPS will give huge savings for VDI since many identical OSes will be running on the same host.

Add memory compression as a last resource to avoid swap also.

All this without any possible compatibility problems of applications querying the amount of RAM.

As Daniel mentions, you can end up with many VMs with the max memory, and inflated balloons, might not look good to many admins.

And lastly ... if you do not want to overcommit, the usefulness of DM is limited.

Tim Mangan wrote re: A closer look at the new "Dynamic Memory" feature of Hyper-V: is it worth it for VDI?
on Thu, Jan 27 2011 6:11 PM Link To This Comment

@Michael - Great to see you blogging here!

I love this new feature (although I am waiting too long for the final release!).  In fact, last year I was thinking of implementing this as an add-on to Hyper-V.  I knew Microsoft added the capabilities to add/remove ram on the fly to Vista and above, and thought that something that worked along this line would be quite valuable.  I'm glad MS did it, because they probably did a better job of it.

I think the potential for this feature is better for non-persistent VDI sessions than for perminent desktop images.  Supercache clearly must be turned off or you are screwed.  I think the % (#3 in screenshot) to go beyond current need is critical to prevent paging in most cases.

michaelkleef wrote re: A closer look at the new "Dynamic Memory" feature of Hyper-V: is it worth it for VDI?
on Thu, Jan 27 2011 6:58 PM Link To This Comment

@VMguy - Id encourage you to look at the ProjectVRC data on density testing and how well dynamic memory works in comparison to others.  An important point is that Dynamic Memory works on cold boot straight away. Another important point is that it works inversely to others in the market - why give a VM an arbitrary amount of RAM and then try to grab it all back? Dynamic Memory hands out what the VM actually needs, when it needs it. That makes much more sense and in ProjectVRC testing on Hyper-V with Dynamic Memory, didnt require security weakening of the W7 guest to gain density.

@Tim - and we want to get it to you ASAP! :) It works well for persistent and non-persistent VMs. Superfetch actually makes a lot of sense for a persistent VM as you now use memory as a cache to disk reads. Memory IO hits are a lot less expensive than a disk hit. Now that the memory ceiling can be solved, you would much prefer to load up RAM a little rather than your disk to maximize perf.

depping wrote re: A closer look at the new "Dynamic Memory" feature of Hyper-V: is it worth it for VDI?
on Fri, Jan 28 2011 3:25 AM Link To This Comment

Disclaimer: I am a VMware employee.

I want to point something out that technically is not correct:

"VMware’s memory management techniques pre-allocate memory and then uses several memory management techniques to reclaim unused memory."

VMware does not pre-allocate memory. So in other words if you provision a VM with 2GB of memory and that VM boots and only 780MB is touched the memory footprint of that VM will be roughly 780MB.

Also, VMware has 4 memory techniques it can use:

1) Transparent Page Sharing

2) Balloon Driver

3) Memory Compression

4) Hypervisor Level Swap

The main thing to note there is that we don't care which OS you are using for most of these techniques so they will work on Linux, BSD, any version of Windows etc.

Nice article by the way,

Duncan

Yellow-Bricks.com / VMware Tech Marketing

depping wrote re: A closer look at the new "Dynamic Memory" feature of Hyper-V: is it worth it for VDI?
on Fri, Jan 28 2011 3:28 AM Link To This Comment

Disclaimer: I am a VMware employee.

I want to point something out that technically is not correct:

"VMware’s memory management techniques pre-allocate memory and then uses several memory management techniques to reclaim unused memory."

VMware does not pre-allocate memory. So in other words if you provision a VM with 2GB of memory and that VM boots and only 780MB is touched the memory footprint of that VM will be roughly 780MB.

Also, VMware has 4 memory techniques it can use:

1) Transparent Page Sharing

2) Balloon Driver

3) Memory Compression

4) Hypervisor Level Swap

The main thing to note there is that we don't care which OS you are using for most of these techniques so they will work on Linux, BSD, any version of Windows etc.

Nice article by the way,

Duncan

Yellow-Bricks.com

Michel Roth wrote re: A closer look at the new "Dynamic Memory" feature of Hyper-V: is it worth it for VDI?
on Fri, Jan 28 2011 6:06 AM Link To This Comment

Hi Daniel,

I think one of the big benefits of DM is that it doesn't require you to be an expert on memory - "so how much memory would my 'typical user' need"? And even if one was to be an expert (like you) then it would still be great educated guess at best. Why go through the trouble? Let the real expert (Windows) figure it out for you.

help4ctx wrote re: A closer look at the new "Dynamic Memory" feature of Hyper-V: is it worth it for VDI?
on Fri, Jan 28 2011 9:18 AM Link To This Comment

@michaelkleef

Interested in your views on SuperFetch as it is something I have been unsure of for a while.

While SF might cache a whole bunch of data which reduces subsequent disk i/o, is there not a possibility that superfetch is actually caching a lot more than you actually need anyway, causing more i/o 'up-front'?

Where more intelligent memory caching capabilities are present, does it not make more sense in most cases for this to be switched off in a VDI envirironment?

@Dan

While in a number of cases your assumption that memory utilisation will increase over the working day, this does not factor in the many users who will logoff completely or who do not adhere to your usage pattern, so memory may actually stay relatively static and make the dynamic memory use case a more realistic proposal.

I believe that you are on the right track, usage patterns definitely need to be takien into account before the use of any DM functionality is introduced. There will undoubtedly be many users where static memory assignment is essential, where others (and my gut feel is that this will be a larger percentage) will still get a good user experience even if their memory footprint is trimmed.

I'd like to see apps delivered via TS or XenApp or even full VM's 'parked' to disk when a session has been disconnected for a configurable time. This would save even more resources and even out memory utilisation even more across the working day.

Great article and subsequent discussion.

(Note: You must be logged in to post a comment.)

If you log in and nothing happens, delete your cookies from BrianMadden.com and try again. Sorry about that, but we had to make a one-time change to the cookie path when we migrated web servers.

Trackbacks

Hyper-V Dynamic Memory & VDI « Josh Mueller wrote Hyper-V Dynamic Memory & VDI « Josh Mueller
on Thu, Jan 27 2011 3:49 PM

Pingback from  Hyper-V Dynamic Memory & VDI « Josh Mueller

Jonathan's Virtual Blog wrote The new "Dynamic Memory" feature of Hyper-V
on Fri, Jan 28 2011 10:06 AM

BrianMadden.com recently posted a great article on the upcoming feature of Dynamic Memory for Windows

A Look At The Dynamic Memory, Hyper-V and VDI Environmen wrote A Look At The Dynamic Memory, Hyper-V and VDI Environmen
on Fri, Jan 28 2011 4:35 PM

Pingback from  A Look At The Dynamic Memory, Hyper-V and VDI Environmen

System Center Virtual Machine Manager wrote The new "Dynamic Memory" feature of Hyper-V explained
on Mon, Jan 31 2011 10:31 AM

Hyper-V Question of the Day: Q: Can you tell me more about Dynamic Memory, such as: What is Dynamic Memory

Dynamic Memory links « UP2V wrote Dynamic Memory links « UP2V
on Mon, Jan 31 2011 3:33 PM

Pingback from  Dynamic Memory links  « UP2V

Dynamic Memory Resource Dump « Thincomputing.net wrote Dynamic Memory Resource Dump « Thincomputing.net
on Wed, Feb 2 2011 10:04 PM

Pingback from  Dynamic Memory Resource Dump « Thincomputing.net

Windows Virtualization Team Blog wrote Windows 7 and Windows Server 2008 R2 SP1 Add New Virtualization Innovations
on Wed, Feb 9 2011 1:05 PM

Virtualization Nation, On behalf of the Windows Server and Cloud teams at Microsoft, I’m pleased

Windows Virtualization Team Blog wrote Windows 7 and Windows Server 2008 R2 SP1 Add New Virtualization Innovations
on Wed, Feb 9 2011 1:17 PM

Virtualization Nation, On behalf of the Windows Server and Cloud teams at Microsoft, I’m pleased

640K Ought To Be Enough For Everyone... wrote Windows Server 2008 R2 SP1 RTM
on Wed, Feb 9 2011 3:03 PM

On behalf of the Windows Server and Cloud teams at Microsoft, I’m pleased to announce that today we released

Windows Server 2008 R2 SP1 and Windows 7 SP1 RTM « Microsoft Desert Mountain SLG Blog wrote Windows Server 2008 R2 SP1 and Windows 7 SP1 RTM « Microsoft Desert Mountain SLG Blog
on Wed, Feb 9 2011 5:52 PM

Pingback from  Windows Server 2008 R2 SP1 and Windows 7 SP1 RTM « Microsoft Desert Mountain SLG Blog

Why is Dynamic Memory so Important? « Core Infrastructure Blog wrote Why is Dynamic Memory so Important? « Core Infrastructure Blog
on Wed, Feb 9 2011 11:31 PM

Pingback from  Why is Dynamic Memory so Important? « Core Infrastructure Blog

Server 2008 R2 SP1 Add New Virtualization Innovations - cliff davies cliff davies wrote Server 2008 R2 SP1 Add New Virtualization Innovations - cliff davies cliff davies
on Wed, Feb 16 2011 4:26 PM

Pingback from  Server 2008 R2 SP1 Add New Virtualization Innovations - cliff davies cliff davies

Windows 7 and Windows Server 2008 R2 SP1 Add New Virtualization Innovations wrote Windows 7 and Windows Server 2008 R2 SP1 Add New Virtualization Innovations
on Tue, Mar 15 2011 4:36 PM

Pingback from  Windows 7 and Windows Server 2008 R2 SP1 Add New Virtualization Innovations

Why is Dynamic Memory so Important? « Core Infrastructure Blog wrote Why is Dynamic Memory so Important? « Core Infrastructure Blog
on Fri, Jan 27 2012 2:27 PM

Pingback from  Why is Dynamic Memory so Important? « Core Infrastructure Blog