Virtualization, Virtual Machine, and Hypervisor
“done on IBM mainframes in the 1960s, but Gerald J. Popek and Robert P. Goldberg codified the framework that describes the requirements for a computer system to support virtualization. Their 1974 article “Formal Requirements for Virtualizable Third Generation Architectures” describes the roles and properties of virtual machines and virtual machine monitors that we still use today.”
― Matthew Portnoy, Virtualization Essentials
“Divide-and-Conquer” is one of the fundamental tenets in computer science, and we see examples of this principle in solving many types of software solutions. That being said — we can divide a single process into multiple execution paths, called multithreading. Likewise, on an operating system, we can run multiple processes, which is called multiprocessing. In other words, we can run multiple execution paths inside a single process and multiple processes on an operating system.
On a similar token, the question is: can we run more than one operating system on single physical hardware? The answer is yes — we can. Virtualization is the software engineering mechanism that allows running multiple operating systems on a single physical hardware. In this chapter, you will learn about virtualization, virtual machine (instance of an operating system), and hypervisor, which is a go-to system between an operating system and physical hardware.
Table of Contents
Virtualization essentially creates virtual computer systems. Virtualization, or in practical terms, virtual computer systems, allows organizations to run more than one operating system on a single server. As a result, virtualization helps in reducing physical servers needs.
As you can notice in the picture above, virtualization is a game-changer with respect to saving costs in buying and maintaining physical servers. Typically, we run one operating system on one server. However, in virtualization, since more than one operating system can be run on a single physical hardware, organizations can reduce their need to buy and maintain physical servers. The reason is virtualization helps them consolidate their servers' needs in fewer servers.
Why is Virtualization Needed?
Let's continue our discussion about virtualization further, imagine a scenario suppose we have a server that is being utilized minimally. Wouldn't it be better to utilize it in some way where we can use this server's resources to create another server inside that server? That's the basic idea behind virtualization.
Let's take another example. As we know, maintaining consistent SLA is very important in critical applications. How can we achieve consistent SLA when running multiple applications on the physical server? Maintaining consistent SLA would be a guessing game as each application would have to compete with other applications' processes for the resources. One way to handle this is to run each application in a separate isolated environment on the same physical server. That way, the application would not have to compete with other processes for the resources. This running applications in their different separate environment would help in providing consistent service level agreement (SLA). We can use the Virtualization technique to create a different independent running environment for each running application on the same physical server.
What can be Virtualized?
Let's talk about what we can virtualize. We can virtualize servers, storage, and networks. This means these hardware constructs can be created in software form as well using virtualization.
Using Virtualization, we can run multiple servers on the same physical server. These virtual servers are called virtual machines or VMs. We will talk about virtual machines later in the section.
For example, we can run Windows and Linux operating systems as virtual machines as two entirely different environments on a single physical machine. Each VM would have its own RAM, storage, and network.
Not only using Virtualization, we can run multiple separate operating systems on the same physical server, but also using Virtualization we can run multiple applications in a completely separated isolated environment on the same physical machine. This type of virtualization is called containerization, for example, Docker container. We will learn about Docker later in this book.
Besides server virtualization, using the Virtualization technique, storage can be virtualized as well. For example, multiple physical disks can be combined to form one logical storage (a form of virtual storage), which can be assigned to a server. Examples are Logical Volume, the RAID (Redundant Array of Independent/Inexpensive Disks) group.
In addition to server and storage virtualization, the network can also be virtualized using the Virtualization technique. Using network virtualization, a physical network can be used by multiple containers (separate runtime environment) running on the same physical server. The physical network is emulated in such a way so that it would be used by multiple containers as if each running container has its separate network.
Another type of virtualization is desktop virtualization. Desktop virtualization enables multiple desktop machines on a single physical server. This is also called desktop-as-a-server.
First, Virtualization increases the efficiency of servers by allowing resource usage optimization as opposed to underutilized servers. Since we can run multiple OS instances on the same physical server, we can efficiently utilize underutilized resources on that physical server.
The next one is derived from the first one — virtualization reduces capital expenditure on physical hardware. By using virtualization or virtual infrastructure we can consolidate many physical servers that are underutilized into a few servers. Thus, saving not only a physical server but also saving on space, power, air conditioning requirements, maintenance, and other things that go with having to have more servers instead of fewer servers to get the same operating functionality.
Now we got an understanding of Virtualization. As we talked about, one of the advantages of virtualization is that we can run multiple instances of operating systems — also called virtual servers or VM – on single physical hardware. The virtualization technique used to create virtual servers, such as Windows or Linux servers, is called a virtual machine.
The virtual machine is also called virtual computer system, or VM, which is the more popular term for virtual machines.
We can think of a virtual machine or VM as a separate isolated container having its own operating system and applications. VMs are discrete, separate, and isolated, self-contained, and completely independent.
Because they are self-contained and completely independent, we can launch multiple VMs on a single physical server. For example, we can have a Linux virtual machine and a Windows virtual machine, both of which can be run on a single physical server in their separate isolated environment. Not just two — this is just an example. We can run many instances of operating systems on the same physical server. Having multiple VMs on single physical servers enables various operating systems and applications to run on one physical server. This physical server is also called host as it hosts multiple VMs.
As we discussed, using virtualization, we can run multiple instances of operating systems on the same physical hardware. In other words, using virtualization, we can set up virtual machines. Now the question is: how do virtual machines — as they run on the same physical hardware — get the computing resources such as processors, memory, or storage?
There is a concept called Hypervisor or Virtual Machine Monitor, using which virtual machines get the computing resources such as processor, memory, or storage. The hypervisor is software that creates and manages virtual machines, and it also mediates communication between hosts and virtual machines.
A hypervisor is a separate and decoupled layer between host and VM. The hypervisor allocates and shares host resources with each VM. In other words, a hypervisor allows multiple guest VMs to share host resources such as processor, memory, and storage of the physical machine. For example, when we install hypervisor software and set up multiple guest VMs on it, hypervisor software will take care of sharing host resources with each VM.
There are two main types of hypervisors: one is referred to as Type 1 or Bare Metal Hypervisor. The other one is referred to as Type 2 or Hosted Hypervisor.
A Type-1 hypervisor runs directly on top of bare metal hardware, acting as a lightweight OS. On the other hand, a Type-2 hypervisor runs on the OS. Since a Type-1 hypervisor runs straight on the hardware, it is also referred to as “Bare Metal,” and a Type-2 hypervisor runs on the OS, that's why it is also called “Hosted.”
Let's talk further about Type-1 or Bare Metal hypervisor. It is installed directly on the hardware. In other words, Type-1 replaces the operating system. In place of the operating system, we install a Type-1 hypervisor.
Typically, a Type-1 or Bare Metal hypervisor is deployed most. There are some genuine reasons why this type of hypervisor is deployed most. Since it is directly installed on the hardware instead of on the OS, it is more secure than Type-2. And the other reason is that since no OS layer is involved, it performs better and more efficiently than Type-2 or hosted hypervisor. Because of security and performance reasons, Type-1 hypervisors are usually preferred for enterprises when deploying hypervisors on their data centers.
Type-2 or Hosted Hypervisor
As you can see in the diagram, Type-2 or Hosted hypervisor runs on the host operating system.
This is another diagram of a Type-2 hypervisor or Hosted hypervisor. In the diagram as you can see that at the bottom layer, we have the physical hardware, then the OS is installed. Since this is a Type-2 hypervisor diagram, first a hypervisor is installed on the OS, then virtual machines are installed. Examples of Type-2 hypervisors that run on host operating systems are Oracle Virtual Box, VMware Workstation, Microsoft Virtual PC.
The main difference between Type-1 and Type-2 is that Type-1 hypervisors are installed on bare metal and Type-2 hypervisors are installed on an operating system.
SK Singh is the founder, a software, cloud, and data engineer. He has been involved in the software industry for around 25 years. He has a bachelor's degree in computer science and engineering from India and a master's degree in software engineering from the Pennsylvania State University. SK has been involved in a wide range of software projects for many governments, private, start-ups, and large public companies in various software engineering roles. He has many professional certifications such as AWS, Hadoop, Kafka, Oracle, Unix, Java, Java-related frameworks, and many others related.