Wednesday, February 20, 2013

Virtual machines and Service Jails

If you are really serious about getting the most out of your hardware, you'll certainly consider using virtual machines. Two, three or even 80 virtual operating systems per physical server is a hard deal to turn down, whether you are an IT shop or a lone developer. It is pretty much something for nothing. 

There are various flavors of technologies out there to virtualize a computing environment. They generally range from heavyweight virtualization solutions (such as VmWare and Virtualbox) which emulate everything in software found in hardware on the machine from the BIOS and devices to the disk; to lightweight virtualization which can be found in certain domains like Apache web server virtual hosts, where a chroot directory and domain routing may the only thing differentiating web hosts.

Heavyweight virtualization tends to be better suited for the desktop, in situations where you'd like to run one OS inside another. Lightweight virtualization tends to be better for servers, because it goes easier on resources and is more abstract, often with no GUI to manage things. For example, VMware will emulate a single BIOS, kernel, drivers and OS per virtual machine. It offers a more comprehensive container, but uses much of the host machine's resources. On the other side of the spectrum, an Apache virtual web host on a server farm will offer customers a complete web publishing domain, but hundreds of virtual hosts can occupy a single physical server.

In the mid-range of all this, are paravirtualization technologies like Xen and FreeBSD jails. Paravirtualization, although not terribly distinct from other forms of virtualization, is where the vitual mechanism is bound closely to the operating system that hosts it. The host is aware of the virtualization technology being used, and shares its own resources with it, such as a kernel. This is generally more efficient if you want to run a bunch of virtual machines of the same OS type within a host, rather than emulate some other operating system on your desktop. 

There are other advantages to the middle-weight paravirutalization approach besides running more VMs per physical machine. Maintenance and upgrades to many VMs can be sourced from a single location on the host. Security and integration is  better understood by the host's development team. Management tools are usually available that enable you to easily monitor, create and destroy VMs. 

Furthermore, the ability to divide VMs by service (database server, login host, development environment, testing environment, web server, build server, source control server) allows a full organizational development and deployment environment to be emulated on a single piece of even-not-so-good hardware. Ideal for a home network with a for a single professional user. Technologies and services found only on large scale systems can be emulated on a single machine that has been subdivided into many discrete machines. 

On FreeBSD, the service jail is the approach to use, and probably the best-integrated and most efficient of all the technologies. Typically,  Xen systems are best used one-per-core on Linux systems - they are a more heavyweight solution than FreeBSD service jails, which can be ganged-up to 50+ machines on a dual-core system and still have good performance.

The requirement, of course, is that you run FreeBSD. This is not so bad. It's pretty much the OS of choice for commercial server farms even without the jails, since it can easily be built from source, the licensing doesn't require you to divulge your source code, and it's completely not owned or controlled by any corporation - much like Linux. But unlike Linux, it's maintained and developed in a more selective, controlled and organized environment. The code base is cleaner, and the engineering standards are higher. Definitely the platform of choice, and still a best-kept-secret among technical people.

No comments:

Post a Comment