Monday, August 16, 2010

On Virtualization

I've been using virtual machines almost as long as I've had computers capable of running them. Back in the 1980s, computers weren't as standardized as they are today, and it became very popular to make emulators that would simulate one computer, running on another, so that you could run software for the emulated machine.

As time moved on, and computers started to standardize upon a common architecture, the emphasis moved from emulating to somehow fooling an operating system into believing that it had control of the computer when in fact, the system was running as just another program. Microsoft Windows 3.1 provided DOS in exactly this way if you had a powerful enough CPU. And a company called VMWare commercialized a system that allowed you to run far more powerful operating systems.

So, what is virtualization? And what is it good for?

Virtualization is simple to describe, but it takes many forms and has even more applications. In principle, if you can run more than one operating system instance on your computer at a time, then you are engaging in virtualization.

In early instances, usually called "emulation" at the time, virtualization was used to provide compatibility with programs written for a different platform. For example, the Commodore Amiga had available for it several PC emulators, programs that simulated a complete IBM PC, allowing a real copy of MS DOS to be installed, and real MS DOS applications be run.

We're still doing it. Microsoft's Windows 7 comes with something called Windows XP Mode. Windows XP Mode is actually Windows XP running inside of a virtual PC - a process designed to follow Windows XP into thinking it's running inside of a real computer. Many Mac OS X users run a tool called Parallels, that makes it easy to run Windows applications without having to reboot into Windows, losing access to their Mac OS X applications.

The same technologies used to simulate whole computers on a user's desktops can also be used for applications other than compatibility. Developers, for example, love virtualized computers. On my development laptop, I'm running Windows 7 as my primary environment, but I also develop for GNU/Linux, and I have VirtualBox installed so that I can run Ubuntu without ever leaving my Windows desktop. In theory, Microsoft's Virtual PC, which is provided as standard with Windows 7, ought to be capable of running Ubuntu, but I've had problems there that I hope will be fixed in a future update of either Ubuntu or Virtual PC.

Having virtual computers as a developer means more than being able to develop for other platforms. Virtual computers can easily be wiped, replaced, backed-up, duplicated, and so on. I can create test environments without worrying about losing my primary environment.

Now, there's another major reason why you might want to use virtualization, but it doesn't lend itself to the "run program that pretends to be a computer on your desktop" approach. Increasingly people are using servers. Servers provide tools over a network, such as web sites, and generally servers need to be reliable, have excellent connectivity, and need to be able to run the applications installed on them without the risk of one upsetting another.

What servers generally do not need is oodles of memory. And given the above requirements, virtualization is a good fit, as long as the virtual servers are all installed on computers that are powerful enough, are reliable, and are located somewhere with good connectivity.

A fairly popular system for managing such an environment is Xen. Xen runs as an operating system in its own right, called a hypervisor, and it encourages the use of paravirtualization, a technique whereby operating systems know that they're not really running on bare computers, but instead cooperate with the underlying virtualization system. Typically, in a Xen set up, a computer is set up with the base Xen hypervisor, a very basic, lightweight, operating system installation called a "Dom0" that can be used to control the system, and then one or more actual servers that do the work. Reboot a Xen system... should you need to... and Xen will shutdown the virtual machines and bring them back up. Your single computer becomes a multitude, running as many applications as you need.

How does this work? Well, I'll give you an example. I have a machine in my closer that is a dedicated Xen box. It runs several virtual computers, all of which, at this point, run Ubuntu.
  • I have one VM that handles my DSL connection. Because this VM handles the connection to the outside world, I can keep the number of services on this to a minimum which helps keep my network secure. People would find it hard to hack into this VM, and they will find it hard to hack into other computers on my network because in order to get that access, they would need to hack my VM.
  • I have one VM that handles my email and runs a website. My wife and I use MediaWiki to store things like shopping lists and package tracking numbers, in a way we can both get at easily. This VM runs the website, and the databases needed by the website.
  • I've set up other VMs for more obscure things I do from time to time. Some time ago I wanted to learn about a system called Kerberos, and so I set up a VM to manage a Kerberos domain. Because this was a virtual machine, I did not have to worry about the configuration messing anything up I was not playing with.
Why use Ubuntu? Well, part of the reason is that Ubuntu is one of the operating systems that supports Xen's paravirtualization system. Another is that Ubuntu has no licensing issues that would cause problems with virtualization, making it easy to create and destroy installations as I need them. But other options exist: if you must have Windows, Xen has a method to run it (alas, without the benefits of paravirtualization), and Xen supports other variants of GNU/Linux, as well as more obscure choices such as Solaris.

For my next job, I'm expecting to have to do a lot of development under GNU/Linux. I'll be developing software for servers, and the ability to create and destroy test servers as I need them will be invaluable. Ultimately, the software will be running on production servers that themselves will be virtualized, making things easier for the system administrators as well as saving the company a fortune in hardware costs. It's a beautiful thing.

No comments:

Post a Comment