Power Management for Hyper-V (Part 1)

If you would like to be notified of when Brien Posey releases the next part in this article series please sign up to our VirtualizationAdmin.com Real Time Article Update newsletter.

Introduction

Although UPSs are a staple in almost every data center, a traditional UPS configuration can wreck havoc on virtualization host servers. This article series explains various techniques for managing battery power in a virtual data center.

Plato once said that necessity is the mother of invention. Well, I have not invented anything lately, but it was necessity that made me go looking for a solution to a problem that I only recently discovered that I had. Let me explain.

The type of work that I do requires me to have a lot of servers. Some are production servers that I use for running my technical writing and consulting business, but many are lab servers that I use to experiment with the techniques that I write about. As you would probably expect, all of these servers are connected to uninterruptable power supplies.

I live in a rural area, so I am used to the power going out on a frequent basis. While power failures are frequent here, they rarely last more than a few seconds. Recently though, we had a power failure that lasted for over an hour. Needless to say, all of the UPS batteries were completely drained before the power came back on.

Normally this would be an inconvenience, but it would not be a catastrophic problem. I use APC UPSs, and they are all include a utility called PowerChute that initiates a graceful server shutdown when the UPS batteries get low. This technique has been around for many years, and it has always worked well for me.  As you would probably expect though, there is more to the story.

What made the recent power failure different from all of the other ones is that this was the first long duration power failure to occur since I virtualized my data center. From what I was able to observe, the PowerChute software tried to shut down my host servers, but it was not smart enough to know that there were a bunch of virtual machines running on those servers. Some of my virtual servers were placed into a saved state, but many seem to have terminated abruptly. This is when I realized that my current contingency plan for power outages was insufficient.

I am happy to report that there are a variety of techniques for dealing with power outages in a virtual data center. The appropriate solution really just depends on which virtualization platform you are using, your network architecture, and of course your budget.

I want to start out by showing you a low budget approach to managing battery power for virtual servers. Once I show you this technique, I will describe some of the approaches that are available to organizations who need a more elaborate solution.

Since my own organization is a one man operation, I am using consumer grade UPSs for my servers. These UPSs work well for my own needs, and they are cheap enough that I don’t have to worry about whether or not I can afford to replace them. This is an important consideration for me because a few years ago a lightning strike destroyed several of my UPSs.

APC includes PowerChute Personal Edition with their consumer grade UPSs. The current version of PowerChute Personal Edition is designed to run on Windows Vista, but as you can see in Figure A, it has no trouble running on Windows Server 2008.


Figure A: PowerChute Personal Edition works with Windows Server 2008

As you can see in the figure above, the PowerChute software provides you with an estimate of the battery’s duration based on the load on the battery, and on whether or not the battery is fully charged. In this particular case, the battery has just over half an hour of power remaining.

In order to protect your computer from an extended power outage, PowerChute gives you the option of beginning to shut down the computer when the battery starts to get low. For example, you can see in Figure B that this server is configured to begin shutting down when the battery has an estimated five minutes of power remaining.


Figure B: PowerChute is designed to shut a computer down gracefully when the battery gets low

While that is all well and good, PowerChute Personal Edition is designed for use with home computers. In my case, PowerChute does not even know that it is running on a server, much less a server that is hosting several virtual machines. That being the case, the server’s behavior must be adapted to mesh with PowerChute’s capabilities. This is easier to do than what you might expect though.

You may recall that when I mentioned my power failure earlier, I said that some of my virtual machines ended up in a saved state, but that others did not. The reason for this is that Hyper-V’s integration services provide an option for how a virtual machine should react when the host operating system is shut down. The default behavior is to place the virtual machines into a saved state. When my power failure occurred the battery went dead before all of the virtual machine states could be saved.

The first step that I recommend taking toward fixing the problem is to manually verify that each virtual machine behaves in the way that you think that it should in the event of a power failure. To do so, open the Hyper-V Manager, right click on a virtual machine, and choose the Settings command from the shortcut menu.  When the Settings dialog box for the virtual machine appears, scroll to the very bottom of the list of settings, and select the Automatic Stop Action option.

As you can see in Figure C, Hyper-V is configured to automatically save a virtual machine’s state if the host machine is shut down. I prefer to use the Shut Down the Guest Operating System option so as to avoid a partially saved state. It is worth noting though that the default option usually allows the server to be brought back online more quickly when the power comes back on.


Figure C: You can control the way that Hyper-V behaves when the parent operating system is shut down

The last step in addressing the low battery shut down issue is to set PowerChute to begin the shut down process at the appropriate time. In my own environment, I simply initiated a shutdown of the parent operating system and measured the amount of time that the entire process took to complete. Since a server may take longer to shut down if it is under a heavy workload, I added a couple of minutes to my shut down time estimate. That means that when my server is running off of battery, it begins the shut down process more quickly than it would otherwise, but it also means that all of my virtual machines should be in a clean and consistent shut down state when the battery eventually runs out of power.

Conclusion

As you can see, it was fairly easy to adapt PowerChute to work properly with my Hyper-V server. In the real world, many organizations are using a more elaborate setup than I am. In Part 2 of this series, I will explain how you can manage battery power for more complex environments, and for organizations that do not run Hyper-V (or VMware for that matter) on top of Windows.

If you would like to be notified of when Brien Posey releases the next part in this article series please sign up to our VirtualizationAdmin.com Real Time Article Update newsletter.

About The Author

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top