Thursday, August 24, 2006

My Moment of Xen

As I write this, my old dual Pentium III rackmount server sits under my desk whirling away at a domU configuration in Xen. If you're unfamiliar with Xen, it is software that allows you to run multiple operating systems on top of Linux or NetBSD using a technique called paravirtualization. If you're at all familiar with virtualization technology, you likely know about the big names, Virtual PC and VMWare. If you're an open source guru, think Bochs and Qemu respectively.

In Virtual PC, an entire Pentium PC is emulated in software. Originally written to run on MacIntosh systems, the entire Pentium instruction set had to be emulated because there was no underlying Intel compatible processor on the system. Though I don't know for sure, I assume the Windows version accelerates some operations much like VMWare.

Though less complete and less capable of running alternate operating systems, VMWare makes up for it in speed. VMWare works a little like a Just in Time compiler in a Java Runtime passing raw machine code directly to the host processor when possible. In a race, VMWare wins, but it's still not the same as running on the host hardware. Nevertheless, my old Pentium 400 running VMWare on Linux could run Windows 2000 almost as fast as Virtual PC running on my Quad-G5 Mac.

Paravirtualization is different. In Xen, everything runs on the bare metal save a few security constraints placed on the guests. The only real emulation is in the devices presented to the domU instances (virtual machines). This gives Xen speed, but it also requires modifications to the virtual machine operating system limiting the available choices. It should be noted, however, that Xen 3.0 includes the ability to virtualize any OS using AMD and Intel virtualization extensions in newer processors, but few have those processors right now.

Admittedly, VMWare provides a compelling alternative to Xen because, to put it bluntly, Xen is complicated and its documentation sucks. VMWare merely runs on top of an operating system and provides very simple means to run a virtual machine from a single file with good performance. Configuration couldn't be much simpler in VMWare. Xen, however, requries a custom kernel in both the host and the guest. The installers provided by XenSource work fairly well, but there's still a steep learning curve when you throw in some variations like an LVM boot device or alternative file systems. Eventually, you almost have to roll your own Xen kernel to get around the limitations of the binary distributions.

So, VMWare looked nice yesterday. However, years ago I jumped off the closed-source, commercial bandwagon when some of my primary tools were orphaned by their creators. Consequently, I always look for an option with source available. Xen is available under the GPL which meets my needs so I kept plugging away.

The mailing lists for Xen are invaluable. Almost any problem I ran into was found in the archives of the mailing list. The user community there seems helpful even to clueless newbs based on what I've seen in the archives. If you stick to fairly standard configurations, you won't run into much trouble, but when you do, head to the mailing list archives and run a search.

Today, I have 4 machines at the colocation facility of which 1 needs to be torn down and rebuilt, another is overloaded, and yet another is in such a poorly cooled case that it needs to be transferred to another system. Xen should give me the ability to move services onto my old Pentium III (which is actually one of our faster machines...stop laughing...I said stop can quit now), reconfigure the vacant machines, and slowly move to a purely virtualized solution.

It's not unusual for us to have one PostgreSQL database wreak havoc on our entire hosting system due to a spike in traffic. With Xen, we can put each such database on its own virtual machine so we can move the databases around to maximize resource use. I know for a fact that the majority of our CPU usage is on two machines. We can now change that.

Additionally, Xen will give us some fault tolerance. It wasn't a month ago that I had a processor fan fail leading to thermal shutdowns by the hardware. Last year, I was chasing dying power supply fans in several machines and had to perform several hardware upgrades requiring more downtime. With Xen, we move the virtual machines to another system, fix the system in question, and move them back.

I know a lot of IT departments are already doing this with VMWare or Xen or other alternatives, and honestly, I've known about virtualization alternatives for a while, but I never consider applying them to my own systems.

Labels: ,


Post a Comment

<< Home