In this first article of a series of ‘more technical’ Heart Internet blog posts, I am going to talk a little bit about how our VPS platform is implemented, using the open source qemu-kvm virtualisation platform.
I think the best way to answer this is to compare it to emulation. What’s emulation? If you remember back in the day, it was all the rage to get a Gameboy, NES, Playstation (or whatever!) emulator for your desktop PC. You would then download the ROMs (software/games) for it, and be very disappointed that, while it worked, it ran very slowly. Getting a faster PC would help, but it was never perfect (especially the more modern games console emulators). It was frustrating because, even though you had a modern desktop (which you thought was fast), the emulation was slow.
An emulated piece of hardware (i.e., that games console’s CPU, graphics and sound hardware, IO layer, etc) are all running as software on your desktop PC. The code that makes up the game is being run inside a software CPU – not a real life hardware one.
Virtualisation is the next step from this; if your guest code is written for your host hardware, it allows you to run your guest (e.g., Windows 7) on your host (e.g., CentOS desktop) hardware directly. The result? Full speed execution – your guest operating system will run as if it’s being run directly on your hardware, with only the additional bits of hardware (IO, network, graphics, sound) being emulated.
This is exactly how our VPS product works.
VPS stands for Virtual Private Server. We have a bunch of really powerful (and I mean *really powerful*) real life Dell servers. They have tens of CPUs, hundreds of gigabytes of RAM, and terabytes of disk, connected to a 1gb internet connection. These big servers run the virtualisation software I’ll describe in more detail below. On these servers are your virtual machines, or VMs, or VPSes (we’ve never really been sure of the plural here, so I’ll go for VPSes).
So, just as I said above you could run Windows 7 on your CentOS desktop, we basically do the exact same thing on a larger scale (because our hardware is so powerful); but rather than having just one VM on our host, we have tens of VMs—all running at lightning speed because they’re on very big servers.
qemu is the name of the non virtualised part of this setup: it started life out as an emulator for various CPU types (ARM, RISC, etc), and along with that it provided emulated graphics, sounds, network and IO. The whole thing all running together provided enough emulated hardware to run any software on it for the desired platform (qemu ARM is actually used in the Android developer kit, to run an emulated Android phone for application development!). This whole thing is called the hypervisor.
However, the CPU is only emulated, so it isn’t very fast.
In modern CPUs, Intel and AMD added special instructions to make virtualisation faster and easier for software authors. KVM, or, kernel-based virtual machine, is the software side of this virtualisation in the Linux kernel. The combination of the extra CPU features and the KVM code in the kernel allows the guest code to run on the CPU directly and therefore is executed at full speed.
So, together with the container of qemu, and the hardware assisted virtualisation of KVM, qemu-kvm was born: it has become the standard for RPM based Linux distributions, and is developed and supported by Red Hat.
qemu-kvm allows any x86 or x86_64 hardware to run any x86 or x86_64 software at full speed in a virtual machine, with full speed CPU and memory access, with emulated network, graphics, sound and disk. Fortunately, the emulated parts are comparatively very simple; they do not hold back performance.
What’s the catch?
The are only two catches:
1. You can only run x86 or x86_64 software using qemu-kvm (most server software is)
2. You can not run x86_64 software on an x86 host (the other way round is fine)
How does this form the Heart Internet VPS product?
It’s really quite simple: we have a bunch of really powerful x86_64 (i.e., 64 bit) servers running Red Hat Enterprise Linux 6 with qemu-kvm installed on them, each of which is set up to build and run guest operating systems of your choice – it doesn’t matter if it’s Windows Server, Ubuntu, Debian or FreeBSD: they’re all x86_64 software, so they all run as if they were on real hardware at real speeds.
The magic with our setup is that we keep a pool of pre-built VMs to a minimum spec, and at order time, scale them up to the desired spec (more RAM, CPU, disk), boot them up, and provide you with their access details: this means that when you want your VPS, it’s up and running in just a few minutes.
Can I play with this at home?
You certainly can! It is somewhat beyond the scope of this article to explain how to set this up, but the basics are very simple:
1. Make sure your PC has a CPU which supports hardware assisted virtualisation.
2. Get hold of qemu-kvm for your Linux distro.
3. Download or legally obtain an ISO for the guest OS you want to run.
4. Use the “virt-install” command line or “virt-manager” GUI tool to set up your VM.
5. Install your OS as you would on real hardware.
6. Away you go!
There is a good link at the bottom of this article about getting started with virtualisation for the Fedora linux distro. It’ll give you a good base understanding of virtualisation.
Could I build a machine at home and put it on your platform?
Technically yes, and it is something we may consider offering in the future—but right now it is not officially part of our VPS product. We respond well to customer demand, so if this is something that interests you, please talk to us (use the customer feedback option from your control panel if you’re an existing customer).
So I hope that has given you an insight into how we setup our VPS platform, and maybe even given you enough information to set up your own home grown virtual machines.
We’d like to continue writing more technical articles, so please let us know if there’s anything specific you’d like us to write about.
Red Hat – https://www.redhat.com
qemu-kvm – https://wiki.qemu.org/KVM
Virtualisation – https://en.wikipedia.org/wiki/Virtualization
Virtualisation with Fedora – https://fedoraproject.org/wiki/Getting_started_with_virtualization
Please remember that all comments are moderated and any links you paste in your comment will remain as plain text. If your comment looks like spam it will be deleted. We're looking forward to answering your questions and hearing your comments and opinions!