From the Canyon Edge -- :-Dustin

Monday, July 13, 2009

Introducing PowerNap!

Ladies and gentlemen, I'm pleased to announce an exciting, new open source project from Canonical for the Ubuntu Server -- PowerNap!

Mark's Karmic Koala announcement alluded to this work when he wrote:
A savvy Koala knows that the best way to conserve energy is to go
to sleep, and these days even servers can suspend and resume, so imagine
if we could make it possible to build a cloud computing facility that
drops its energy use virtually to zero by napping in the midday heat,
and waking up when there's work to be done. No need to drink at the
energy fountain when there's nothing going on. If we get all of this
right, our Koala will help take the edge off the bear market.
I have just uploaded PowerNap to Karmic, and we are well on our way to integrating the technology into the 9.10's Ubuntu Enterprise Cloud.

Actually, I spent last week in sunny Santa Barbara, California working with Dan Nurmi, of Eucalyptus Systems. We shot some amateur digital videos of Ubuntu Karmic Servers, PowerNap/PowerWake, Eucalyptus, and a Watt meter in action. I'll get those posted soon!

I'll go into much deeper technical detail on the design and implementation of PowerNap over the next few weeks in subsequent posts, but I'll give an overview here...

How Does It Work?

PowerNap operates sort of like a screen saver for servers. Besides watching the console and terminals for keyboard activity, it also watches the system's process table for activity.

An administrator defines a list of regular expressions describing some critical MONITORED_PROCESSES that should be running. When powernapd notices that all of the MONITORED_PROCESSES have been absent from the process table for some configurable ABSENT_SECONDS, powernapd emits a warning to all users of the system that it will run powernap, unless canceled within the next GRACE_SECONDS.

Sample Configuration

In the Ubuntu Enterprise Cloud case, the configuration file, /etc/powernap/config, might look something like:
MONITORED_PROCESSES = [ "^/usr/bin/kvm " ]
Thus, if no instance of kvm runs for 5 minutes, then the system will emit a warning, and powernap after a 1 minute grace period.

PowerNap Now!

Alternatively, a system administrator can force the system to powernap immediately by either running /usr/sbin/powernap directly, or sending powernapd the "now" signal with: service powernap now. In fact, this is what the Eucalyptus Node Controller does, such that it can maintain state, and directly control its managed nodes.

What constitutes a powernap?

So, powernap will first check if /etc/powernap/action is executable, and if so, it will run that file. This will allow you, as an administrator, to run any arbitrary script or program of your design when powernapd determines that your server has become idle. Your script could send an email, for example.

echo "Inefficient server, wasting energy" | mail
But in the default case, powernap will check if your server supports suspend-to-ram, and if so, it will pm-suspend your system. Otherwise, it will suspend-to-disk, or power the system off, depending on the sleep states supported by your hardware.

Slick, huh? :-D

Beyond the Cloud

While PowerNap is bespoke for the Ubuntu Enterprise Cloud, I have implemented it in manner that I hope is generically useful.

In fact, I'm currently using PowerNap on my Mythbuntu front ends! My configuration currently looks something like:
MONITORED_PROCESSES = [ "mplayer", "vlc", "xine", "mythfrontend.real", "xmms", "gthumb" ]
My hardware supports S3 suspend-to-ram, so this is great! If 4 minutes go by, where I'm not running any of my media players (mplayer, vlc, xine, mythfrontend.real, xmms), I'm given a 1 minute grace period, and then my system suspends. I have configured wake-on-usb and wake-on-lan in the BIOS, so I can resume the system in a couple of seconds either by tapping a key or sending a WoL magic packet.

But in the mean time, I've reduced the power consumption of 4 systems by 90%, for most of every day while I'm not directly using MythTV!

What about Waking Systems?

Which brings me to PowerNap's kid brother...PowerWake. /usr/bin/powerwake is another Python script. This script is designed to be a smarter, remote waking utility. Currently, it supports wake-on-lan, but it will eventually support other mechanisms, such as IPMI, and perhaps NUT.

With respect to wake-on-lan, it's "smarter" than some other wake-on-lan utilities because it uses a hierarchy of cache files, configuration files, and the current arp table, such that you can wake a system by MAC address, or IP address, or hostname. I find this far more convenient than trying to remember or look up MAC addresses. powerwake respects static configuration in /etc/ethers and maintains a dynamically learning cache of known MAC addresses in /var/cache/powerwake/ethers.


I'm eager to hear what other uses you might have for PowerNap and/or PowerWake for your data centers, basements, and living rooms!

Saving a few Watts,


  1. Interesting. Could you please make sure that powerwake knows how to handle multiple Ethernet interfaces? If I run

    powerwake myserver

    It should do a dns-lookup for myserver and then look at the routing table to decide which outgoing interface it should send the etherwake message on.

  2. Very interesting! I'll be montioring the progress for sure

  3. Can you explain the cloud scenario a bit more?

    Is powernap meant to run on virtualized clients or the host system?


  4. Jef-

    I'm sorry if that wasn't clear... PowerNap is meant to run on the system(s) hosting virtual machines.

    When one of those systems goes un-utilized (ie, no virtual machines running), PowerNap notices this and moves the physical machine to a lower power state (like S3 suspend).

    When the Cloud Controller receives some new requests that demand new virtual machines, it would first look for a running host that has sufficient capacity to service the request, thereby keeping the overall cloud in a "compressed" state.

    However, if demand requires, the Cloud Controller would PowerWake one of the sleeping hosts, bringing it online and increasing the current capacity of the cloud, such that it could service the new request.

    Is that more clear?


  5. Yes much more clear.

    Your home usage example sort of confused me as its managing the power consumption of long lived but very idle services. The cloud scenario is more about managing the power consumption costs of potential capacity assuming services that are seldom idle or perhaps typically short-lived.

    I have to wonder, can you layer it to provide both types of power consumption management? What if you have a set of long lived virtual clients, each with critical work loads(in the powernap sense) like you described in your home server example? Could you powernap individual clients? And then powernap the host if all the virtualized clients are also power napping? And then powerwake the host and the clients as needed?

    Does the same sort of power savings you described for your home server setup applicable to long lived virtual clients and the host that run them? Any long lived virtual clients will keep your host awake and drawing power even if the virtual client is not doing critical work..just as in your home server example.


  6. I'm wondering how this would work in a compute cluster environment. Definitely interested in following this project. It's as a wise man once told me, "Data Centers aren't about computers, they are about power."

  7. Installed powernap 1.9 on my new NAS/HTPC computer. New to Ubuntu, and i'm having a difficult time to get my machine in some kind of power off mode (hibernate/suspund etc), because there simply is no software for this reason.

    Powernap comes to the rescue. I installed it, but think the default settings are strange. I'm using powernap in Ubuntu 10.04, were the process "/sbin/init" is always present in the process list. If i'm correct this will cause my machine to keep running. The 5 minute limit is never reached. It would more sense, in my opinion, to enable the line that checks on the presence of a ssh deamon.

    I hope the addition to check on network activity will be included soon in powernap. That would make this utility complete.

  8. Hi, Dustin. Can powernap be used to bring a system to halt if there is no network activity on it?


Please do not use blog comments for support requests! Blog comments do not scale well to this effect.

Instead, please use Launchpad for Bugs and StackExchange for Questions.