Virtualization, Virtual Machines and Hypervisors
Virtualization (in computing) is the process of creating one or more completely isolated “virtualized” environments inside a physical computer/machine. Each of these environments behaves like a completely isolated “real” computer by emulating softwares and hardwares like operating systems, storage (disk), networking, peripheral devices, etc.
If you’ve SSH’ed into small remote servers hosted by cloud providers (AWS, GCP, DigitalOcean, etc.) then you have already interacted with virtual machines (remotely). In fact, virtualization is what made cloud hosting possible and popular. You could also run a virtual machine (virtualized environment) locally.
The software that allows you to create, run, monitor and destroy these virtual machines (VMs) is known as a hypervisor (also known as virtual machine monitor, VMM or virtualizer). So basically, on a single physical hardware or machine, using a hypervisor, one can create and run multiple VMs that run completely different operating systems and applications in each of the VM.
The computer running a hypervisor is called a host machine and every virtual machine (VM) is a guest machine. The OS running inside a VM is also known as the guest OS whereas depending upon the type of hypervisor (we will cover below), the OS running on the host machine is known as the host OS.
A hypervisor performs a couple of tasks like:
- Split the hardware resources of the host machine such as CPU, memory and storage and allocate them amongst one or more running VMs. The VMs won’t be able to consume more resources than what’s allocated to them (respect their limits).
- Apart from hardware allocation, there’s a lot of management that also comes into picture. For instance, the hypervisor has to take care of scheduling processes between the CPU cores of the VM and the actual physical core of the machine since multiple VMs may utilize the same physical cores.
- Let different VMs use different softwares altogether – operating systems and applications. So a physical machine with Windows as its host OS will be able to run multiple VMs with their own choice of guest OS – Windows, macOS or Linux (Ubuntu for instance).
- Ensure isolation between multiple VMs so that they cannot interfere with one another when running at the same time.
From a DigitalOcean blog piece (for a slightly easier understanding in layman’s terms):
The hypervisor figuratively carves up the resources of the underlying bare metal server, so that your VM receives a portion of the physical machine’s capabilities. While the servers in our data centers feature Intel processors with 20 or more physical cores, hundreds of GB of RAM, and multiple terabytes of disk, your virtual machines can utilize only a fraction of that total capacity.
It’s this virtualized architecture that allows DigitalOcean to efficiently load our servers with multiple customers’ workloads – and ultimately offer our Droplet servers for as little as $5 per month.
Note: Sometimes the hypervisor is not just limited to being a software but is a combination of software, firmware and hardware.
There are 2 types of Hypervisors – Type 1 and Type 2.
Type 1 – Native or Bare-metal Hypervisor
These hypervisors are directly installed on empty bare metal hardware, i.e., there’s no existing host operating system. They run directly on the underlying hardware/machine acting as the OS themselves. Some examples of Type 1 hypervisors are KVM, Xen, VMWare ESXi, Windows Hyper-V, Citrix XenServer, etc.
Type 1 hypervisors are primarily used in enterprise data centers. For instance, they have been integral to the development of cloud computing. Almost all cloud providers use them to provide highly optimized virtual private servers (VPS) or individual VM instances to their customers. Generally, a single large host machine runs multiple VMs shared by multiple customers.
Here’s a list of some of the popular cloud providers and the Type 1 hypervisor that they use:
- AWS EC2 use their in-house Nitro hypervisor which is a combination of hardware and software based on KVM
- GCP Compute Engine VMs uses KVM
- Azure uses Azure hypervisor that is based on Windows Hyper-V
- DigitalOcean droplets use KVM
- Linode Compute VMs use KVM
Type 2 – Hosted Hypervisor
These hypervisors are installed and run on top of an existing host operating system (Windows, macOS, Linux) just like an application in the host OS. So the host OS sits in between the machine and the hypervisor. Examples are VMWare Workstation, Oracle VM VirtualBox, Windows Hyper-V, etc.
Type 2 hypervisors are useful for individual users for personal use. People use them to run a different OS on their host OS. For instance playing games in a Windows VM on an Ubuntu Linux host. You can try installing Oracle’s VirtualBox, followed by installing your desired operating system and then some apps to play around with.
Earlier software engineers also used these hypervisors to create isolated development environments on their local machine that’d be pre-configured. Although this practice has been replaced with containers (like Docker) which are less resource-intensive. Containers share the host’s kernel and system resources.
There are certain benefits of virtualization, i.e., using virtual machines with the help of a hypervisor, like:
- Cost savings on hardware and electricity. Bigger and lesser machines can run multiple VMs and do more simultaneous work.
- Portability of VMs or applications that allow moving them from one physical machine to another easily (think machine images). This helps with aspects like scalability, disaster recovery, etc.
- Run OS dependant applications (like a game that only runs on Windows).