Friday, January 11, 2008

Virtual Machines

I have been fascinated with the idea of virtual machines since I first heard about the concept in the late 60s. I think it was the University of Michigan who modified an IBM 360/65 and made it capable of running multiple isolated program spaces on one box. They called it the 360/67 CP-CMS, and it became the basis for the new 370 line introduced a few years later. Virtual machines were in the domain of mainframes at that time, and it was impossible to visualize that I would be using the concept on my laptop 30 years later. Who knew?

In my work as an architect and presenter for IBM in the 90s, I had the need to have access to the latest web application server product we were selling. These were huge cranky beasts that often corrupted the operating system when they were installed. One version used DCE as a transport protocol, and that thing had the nasty habit of locking up your computer if you changed the timezone. Since I traveled constantly with my trusty ThinkPad laptop, I could not afford to have one of the early WebSphere installs screw up my critical presentations, contact, and email. So, I started playing with VMware workstation.

I think the first version of VMware I used was 4.5.x. I managed to host a Windows NT guest on a Windows NT host, and thought I had really accomplished something! In fact, the limits of memory (I had my laptop maxed out to 1GB) limited how big a VM I could deploy before page thrashing set in, and therefore limited its usefulness. Nevertheless, I knew that VMware was on to something.

When I retired from IBM, I decided to acquire a big desktop system to experiment with. I got a dual-core amd_64 box with 4GB of RAM and a 300GB sata drive. Add a decent video card and wide-screen monitor, and I now have credible Linux-based host system, which can support multiple VMs simultaneously. And it rarely pages to hard disk.

I also experimented with various open-source virtual machine monitors, such as Xen, Virtual Iron, VirtualBox, and KVM/Qemu. For various reasons, I found all of them lacking in some respect. Some just didn’t support the network card I have, some could not provide peer networking, some were so badly documented that I gave up in disgust. I settled on VMware Workstation 6.x because it is stable and it has a good set of features that make playing with VMs enjoyable. I am a advocate of open-source software, but in this case, the proprietary product has set a standard that the others have not yet met.

I maintain two VMs, one the latest Ubuntu, and one Windows 2000, as template systems. If I decide to build a new VM for some specific purpose, I clone it from one of the templates. This saves a lot of setup and configuration, and it gives me confidence that my test environment is stable.

I have found that not all Linux packages uninstall cleanly, often leaving cruft lying around after uninstalling. That is not unique to Linux, of course, but it makes installing and testing complex software sort of like climbing out on the wing of your airplane to service the motor. Things can go very wrong, and you could lose access to irreplaceable data and spend countless hours rebuilding systems if you are not careful. And, in my opinion, backups are not a sufficient safety measure.

So, my solution to that problem is the VM sandbox. I spin up a VM, give it a unique hostname, and voila, it is another peer workstation on my network, with access to data on other servers in my subnet and access to the internet in general. Now I can go ahead and download and install new packages and test them. If they prove useful and of general utility, then I promote them to the template system. If the package disappoints, I can always blow the sandbox image away and try something else.

Virtual machines are also very useful while building web applications. You can set up a VM to be the web server, another as the database server, and several more as mid-tier application servers. They all run as peers on the network and allow sophisticated testing in close-to-real-world environments.

No comments: