How Does Virtualization Work Exactly? (Cloud Explained Series)
In the first article of this series, we explained that the existence of virtual instances like VPS is possible thanks to technology called virtualization. But how does virtualization itself work in detail?
In the second part of Cloud Explained Series, we’re going to talk about how a virtual machine is connected to the hardware, what kind of software is necessary to perform virtualization and we’ll mention some of the most popular tools used for virtualization.
Table of Contents
- What is Virtualization?
- How Does it work?
- Notable Software for Virtualization
- Benefits of Virtualization
- Virtualization at Contabo
What is Virtualization?
To put it simply, virtualization is a process when a physical computer creates another, virtual computer. This virtual computer is what we usually call a VPS, a virtual machine or cloud instance. It has assigned a certain capacity of the original physical computer. Similar to your normal computer, every instance is equipped with a certain amount of RAM, CPU cores, hard disk, and other resources. Although virtual, the newly created instance can be used to perform the same operations as the original non-virtual computer.
For an easy example from personal computing, look at this screenshot:
As you can see, the desktop clearly belongs to Microsoft Windows. But in the window on the left, the Linux Ubuntu is running. In this case, the host operating system is Microsoft Windows. Then we’ve created a virtual machine equipped with Ubuntu Linux. Ubuntu virtual machine is running on top of Windows. Both virtual and host operating systems are independent of each other and can run simultaneously.
The same principle applies in a commercial setting. The difference is that the host system is running on a physical server somewhere in a data center. You as a customer can order chunks of the physical server capacity in the form of a VPS. How much of this capacity is up to you and your wallet, but modern physical servers are powerful machines, and you most likely use just a fraction of the whole performance. For instance, our biggest VPS XL runs on 10 CPU cores and 60 GB of RAM while the host system has 32 CPU cores and 512 GB of RAM.
Virtual instances are fully functional virtual computers with their own operating system. At Contabo, customers can choose from many operating systems, or even deploy their own custom .iso image:
This is all possible thanks to virtualization.
The idea of splitting one physical server into multiple independent environments goes way back to the sixties and seventies, when engineers from IBM experimented with so-called time-sharing. The motivation remains the same – multiple people can use one computer and share its resources.
Virtual Machines, Virtual Instances and VPS
As confusing as it can be, the IT community uses different terms for labeling virtual computers. Some describe them as virtual machines (VMs), some use the term virtual or cloud instances.
Other terms are used for sales purposes. The term cloud is closely related to virtual machines, describing more of them working together, as we explain later. Individual instances are most often called VPS. Or the providers use the product name, like Amazon’s EC2 or Digital Ocean’s Droplet.
They all refer to the same concept.
Virtual Machines and Containers
Both are a hot topic in the IT industry right now. They both use virtualization. But while virtual machines consist of a whole independent virtual operating system, containers are small and portable instances sharing the capacity of a host operating system.
We will talk about containers in the next article of Cloud Explained Series. This article is focused solely on virtual machines.
How Does it work?
Modern-era Virtualization Uses Hypervisors
In the early days of virtualization, a new instance was created using software virtualization on the original operating system. This proved to be less effective and modern virtualization is mostly hardware-based. Hardware resources such as CPUs, RAM and others are allocated dynamically to any number of virtual instances. The software responsible for this distribution is called a hypervisor.
Hypervisor is a software installed directly on the server’s hardware. It is somehow similar to a hardware driver in the OS kernel that can very quickly communicate with the bare metal parts. That makes hypervisor software similar to various drivers that your computer uses to communicate for instance with a printer or with a Wi-Fi card.
There are two kinds of hypervisors – type 1 hypervisor and type 2 hypervisor. The type 1 hypervisor is communicating directly with the hardware while type 2 needs an operating system in-between.
Both hypervisors are still used, but for commercial settings, type 1 is usually deployed because it has a shorter response time. Type 1 hypervisors are also sometimes called “hosted hypervisors”. You may have already heard names like Hyper-V, XEN or Citrix, those are all commercial type 1 hypervisors.
Type 2 hypervisor is suitable for individual users who want to have an extra operating system on top of their default OS. Type 2 is more versatile, making it a perfect tool for software development. Have you noticed the name of the app running our virtual Ubuntu in the first picture? That is Oracle VM VirtualBox, a type 2 hypervisor.
How Do Hypervisors Manage Hardware Resources?
From customer’s perspective, virtual machines behave in the same manner as if the user is working on a regular non-virtual computer. While other virtual instances are located on the same physical server, their users are not aware of their neighbors.
Hardware capacity for each instance is constantly changing depending on the actual need of the guest OS. Hypervisors will send just enough resources from the hardware to cover the request of a particular virtual machine. Sometimes your virtual machine uses more resources and sometimes your neighbors put a heavy load on the physical server, while you use minimum RAM and CPU capacity. Exactly this principle makes modern virtual instances resource-savvy and hence affordable.
Notable Software for Virtualization
In the previous chapter, we’ve explained that you need a special software to create virtual instances, namely a hypervisor. Let’s take a quick look at some of the most popular hypervisors today. Because this series is primarily about cloud, we focus on hypervisors you can find in enterprise settings.
All mentioned hypervisors in this chapter are type 1 hypervisors, meaning they are installed directly on the hardware without any operating system in-between.
This pioneer in commercial virtualization was purchased by Citrix in 2007. The Xen Project was developed in late 1990s at Cambridge University and marks one of the milestones of commercial hypervisor deployment, as the goal of the project was:
"Our design is targeted at hosting up to 100 virtual machine instances simultaneously on a modern server." Computer Laboratory, University of Cambridge
is currently dominating the enterprise sector.
• Most popular hypervisor on the market
• Wide array of optimalization for experts
• Free for testing, costly paid version
Microsoft’s own solution focuses on customers that rely entirely on their products without using open-source software.
• Easy implementation for companies built on Microsoft products
• Less expensive than vSphere, but also less features
is a low-cost solution for commercial projects. The company is known as an industry leader in the field of 3D graphics virtualization
• More affordable than Hyper-V and vSphere
• Perfect for companies using both Linux and Windows
• Optimized for 3D graphics
Is an open source software built directly into Linux operating system, turning the Linux kernel itself into a hypervisor. Although open-source, it’s offered as part of commercial packages, for instance Red Hat Virtualization Suite.
• Linux native – easy to integrate and fast for any Linux OS
• Cost-effective thanks to being open-source
KVM is currently Contabo’s preferred hypervisor, visit chapter 5 for more information
Benefits of Virtualization
Virtual Machines are Easy to Scale
Because the VPS instance is virtual, it’s very easy to upgrade your hardware capacity, adding more RAM or more CPU cores or more hard disk space. Individual users use just a tiny fraction of the overall provider’s server capacity. Your provider can instantly allocate more capacity from the physical instance.
Contabo, for instance, offers resizing via API and directly in the control panel:
Scaling up your VPS instance does not interrupt your data in any way. The upgrade is seamless and immediate, the only thing that changes is the new specifications.
Note that we are not only talking about changing parameters coming from the same physical server, but also about the ability to move instances to a different physical server. A provider can move any instance to another piece of hardware without stopping any workload.
Virtual Machines are Affordable
The price tag for VPS is many times lower than for a dedicated server. While you can purchase a VPS for €3.99 at Contabo, a bare metal server from our standard line will cost you at least €139.
With the rise of VPS, even small businesses and individuals can have the independence that comes with a private virtual server, their own IP address and their own operating system.
That being said, it would be wrong to understand VPS only as a low-end solution. Large corporations sometimes buy VPS in bulk to build very complex cloud setups. Each server typically has just one specific type of task to execute, and the result is passed on via API to the next instance which performs another task. This way it’s easy to scale tasks that are becoming bottlenecks. It’s also a better setup from a security and debugging perspective. Sometimes these clusters can get very big. Our biggest customers use thousands of VPS simultaneously.
Virtual Machines are Safe
Each of the virtual machines runs in a separate environment independent of other instances. For that very reason, developers use virtual machines as safe sandboxes when testing new things or interacting with potentially malicious content. When something goes wrong, other instances are intact.
But the independence of each VPS is also important not only for developers. In case one instance fails or is attacked by a hacker, the rest of the network will remain unaffected and the business will still run as usual.
Virtualization at Contabo
We use hypervisor software KVM – Kernel-based Virtual Machine as a standard hypervisor. KVM allows near bear-metal performance and support of so-called para-virtualization drivers. These drivers are designated to enhance performance of guests who run heavy tasks and applications.
In-house expert Tino Lehnig, Cloud Architect
“We hold KVM in high regard not only for its performance, but also for the flexibility. Our Linux-based KVM host system allows us to build our own bespoke orchestration tools to facilitate software deployments, performance monitoring and automated load balancing.” – says Tino Lehnig. “Over the years, we have built several custom tools to make Contabo customers’ experience smooth as possible.”
Contabo has implemented measures to balance the load on physical servers to provide customers stable performance. We measure performance of our host servers in real time to identify servers which are near limit of the server’s capacity. If such a situation occurs, we migrate some virtual machines from one server a to another that has more resources available at the moment– without that particular user even noticing.