Ultimate Guide to Virtual Machines for Beginners
What are Virtual Machines (VMs)? How do they work? what are virtual machines used for? How can VMs benefit my business?
When discussing cloud computing and related concepts like desktop virtualization, Virtual Machines (VMs) are one of the major buzzwords frequently thrown around. Yet, what actually is a VM?
In this beginner’s guide to Virtual Machines, you’ll learn everything you’ll need to know about VMs, and by the end of this guide, you’ll be able to answer key questions about VMs, including but not limited to:
- What are Virtual Machines (VMs)?
- How do VMs work?
- Different types of virtualization in a Virtual Machine
- Different types of Hypervisors
- Pros and cons of Virtual Machines vs. traditional (physical) computing
- What is a hypervisor?
- What are virtual machines used for
Without further ado, let us begin right away.
What are Virtual Machines (VMs)?
A Virtual Machine (VM), simply put, is the virtualization or emulation of a traditional (physical) machine.
A desktop computer or a laptop is a physical machine, and a VM is technically a software (a program) that behaves and functions almost exactly like these physical machines: it has its own Operating System (OS) and runs its own applications.
If a physical computer has components like CPU, GPU, hard drives, RAM, and network cards, then a VM also virtualizes these components (i.e., virtual CPU and virtual RAM.)
In practice, a VM runs on a physical computer (called a physical host), and a physical host can run multiple VMs that function separately from each other. A VM is also independent of its host, and can run a different OS than its physical host (i.e., a physical Windows server running a virtual macOS VM.)
Different Types of Virtual Machines
There are two basic types of Virtual Machines available:
- Process VM
The VM also allows only a single process to run on a host machine, essentially by masking the information of the underlying hardware or OS to allow the physical host to run the process, regardless of the platform/OS running on the host. Java Virtual Machine is a good example of a process VM.
- System VM
Full virtualization of a physical machine. A system VM utilizes a hypervisor to access the underlying physical host’s resources.
How do Virtual Machines Work?
At the core of all Virtual Machines is virtualization technology using hypervisors.
While different implementations of VMs may vary in practice, all VMs can be separated into four basic components:
- A physical machine and its OS as an underlying system in which the VM runs upon
- A hypervisor. A software layer that facilitates communication and translation
- Multiple Virtual Machines access the physical machine’s resources by communicating with the hypervisor
- Applications and processes that run on the virtual (guest) OS
A hypervisor is a specific type of software that is needed to create Virtual Machines (guest machines) on a physical host (host machine).
Virtualization uses a hypervisor to simulate virtual hardware components (i.e., virtual CPU or virtual hard disk.) The hypervisor software takes resources from a physical component (like a physical CPU), then assigns these resources to the VMs as a virtual component.
The hypervisor is also responsible for scheduling operations between multiple VMs, to ensure they don’t overrun each other while consuming resources.
Ultimately, hypervisors make it possible to use more of a physical host’s available resources on VMs while ensuring guest VMs stay independent of the physical host’s hardware. This will also translate into improved versatility, allowing the VMs to be easily migrated between different physical servers as needed.
Because hypervisors allow a single physical host to host and run multiple VMs, which will eventually provide the following benefits:
- Improved speed
Hypervisors allow VM instances to be created instantly, so it’s also easier to provision resources as needed.
Since hypervisors allow the OS to be independent of the underlying hardware, the OS and applications can be hosted from a wide variety of physical devices (i.e., a Linux thin client can run virtual macOS). Hypervisors allow access to software and applications without the typical hardware or OS limitations.
Hypervisors allow a single physical machine to host multiple VMs, so it allows for more efficient usage of physical resources. When a single physical computer hosts two VMs, for example, then it will be more cost and energy-effective than a traditional physical computer running just one OS for one user.
Since VMs operated by hypervisors are entirely independent of the physical host, then The IT team can have more versatility in moving VMs between physical machines, as well as in allocating resources across multiple servers as needed. When, for example, more computing power is needed, the hypervisor can allow the IT department to simply add new VM instances in no time to answer to the demand.
Different Types of Hypervisors
There are two basic types of hypervisors used in VM implementations:
- Type 1 hypervisors
A hypervisor of this type is a built-in part of the physical host. So, the VM interacts directly with the physical host to request hardware resources and doesn’t involve additional applications or software in between. Physical machines using type 1 hypervisors can only be used for virtualization, and separate hardware or solution is needed to handle other end-user activities like managing authentication. Microsoft Hyper-V and Citrix Hypervisor are two popular examples of type 1 hypervisors. Due to how it works, type 1 hypervisors are also called bare-metal hypervisors.
- Type 2 hypervisors
This type of hypervisor is a software application that runs on the physical host’s OS. Also called “hosted hypervisors,” they are a software layer that is responsible for relaying VM requests to the physical host’s OS and vice versa, passing the provisioned resources from the physical host to the VM. Since there’s an additional layer in the process, type 2 hypervisors are slower than type 1, but the physical host will not need to be solely dedicated to virtualization. It can still run VMs, and the users can still use the system as usual.
In general, type 1 hypervisors are more commonly used in data centers or server-based environments, while type 2 hypervisors are more commonly used by individual users and small businesses that don’t have dedicated physical machines (i.e., dedicated servers) used solely for virtualization.
How Hypervisors Work
The main function of a hypervisor is to separate a machine’s software from its hardware, which essentially allows virtualization.
This is made possible via the work of three different modules:
Routing the instructions from each VM instance to one of the other two other modules.
Receives instructions from the dispatcher and is responsible for allocating the system resources to be provisioned to each Virtual Machine instance.
Consists of stored routines that are executed whenever the Virtual Machine executes a privileged instruction.
With these three modules, the hypervisor isolates each virtual machine, allowing them to run separate OSs simultaneously and keep them separate. So, if one VM crashes or cannot operate for one reason or another, the other VMs can continue to run.
what Are Virtual Machines Used For
Virtual Machines (VMs) are initially developed for virtualizing servers to help IT teams in managing their computing resources and improve efficiency.
Nowadays, however, VMs can be used in various use cases and can be deployed to accommodate different levels of resource and processing power requirements.
VMS can also be utilized in situations where the tasks performed are considered too risky to carry out in a physical machine, for example, testing brand new (and potentially vulnerable) applications, as well as accessing virus-infected resources.
This is possible because VMs are considered fully separated from their physical hosts, so even when an application within the VM is infected by malware, it won’t affect the host computer or server.
Benefits of Using Virtual Machines
Virtual Machines allow individuals and businesses to leverage cloud-based virtual desktops, allowing users to access a full desktop experience (i.e., Adobe Photoshop application over a virtual Windows machine) remotely, anytime, anywhere, and from any device.
By allowing employees to be able to easily access the essential tools to finish their work, companies can allow them to be more productive.
Leveraging Virtual machines can offer numerous benefits to businesses:
Because the organization can host multiple instances of VMs on a single server, it can save money it would otherwise need to invest in extra servers.
In a traditional model, when the company needs to add another workstation for an end-user, then it needs to purchase a new physical machine. With VM deployments, the company can simply deploy another VM instance on the same server to achieve the same outcome.
Virtualization technologies allow the company to leverage each physical machine so it can make the most of its resources, improving cost-efficiency.
2- Improved Security
Since Virtual Machines are isolated from the physical host’s OS, exposure to security threats on the VMs and applications/processes running within the VMs will not affect the underlying host.
For example, if a VM is infected by malware, it won’t affect the host’s OS. This makes VMs ideal for testing new applications or for executing other potentially vulnerable tasks.
This makes VMs ideal for testing or using high-risk and vulnerable applications. If there’s any problem or damage caused by the application or network, we can simply shut down the guest VM to prevent the problem from spreading.
On the other hand, when a VM instance is compromised, we can easily revert it to the latest known stable version.
This allows VMs to improve the reliability of the whole system by reducing or even eliminating downtime.
Since Virtual Machines are sandboxed, and we can use different ISAs (Instruction Set Architectures) than the physical host machine, isolation between the VM’s OS and other environments can be maintained. This way, it’s easier for the IT department to perform maintenance, troubleshooting, and even formating/updating the VMs without affecting the other VMs and the physical host.
This is especially important for companies that regularly perform experiments in their day-to-day operations. This company can simply create different testing environments in separate VMs for testing different runtime environments. This way, when one application environment is updated or modified, it won’t negatively affect another application in the same physical host.
With VMs, we can easily add or delete VM instances depending on our business’s current needs.
Adding a VM instance is quick and simple, so organizations can respond better to sudden increases in demands, much faster than investing in a new physical server and installing different OSs on the servers.
On the other hand, we can simply delete VM instances when employees are leaving the company or when the company is forced to scale down.
Key Considerations When Using Virtual Machines
While, as discussed, there are so many benefits to using VMs in your day-to-day operations, and these benefits should outweigh all the drawbacks, there are still several concerns you may need to pay attention to before committing to any Virtual Machine services:
Even with the latest technologies, VMs are not yet as efficient as physical machines in using hardware resources. This is mainly because the VM’s application layer must first interact with three different layers when accessing physical resources: its virtual OS (guest OS), hypervisor layer, and the physical host’s OS before it can access the hardware layer.
Meaning, you’ll need to decrease your expectation when estimating resources requirement for VMs.
2- Performance Issues
While VMs are mostly reliable, running multiple Virtual Machines on a single physical host can be a great burden on the system and can cause various performance issues.
A common cause for this issue is when one or more VM running on the host machine is tackling a heavy workload, which burdens the host machine and negatively affects the performance of other VMs running on the same host.
To tackle this issue, many cloud-based VM services and servers now offer elasticity features (the ability to automatically provision and de-provision resources depending on the current workload of each VM.)
The main benefit of using Virtual Machines (VMs) is to reduce the amount of physical hardware (i.e., servers) that would otherwise need to be purchased by the organization.
A single physical server can run multiple VMs, so it will improve the cost-efficiency of the infrastructure, allowing the company to maximize the ROI of each physical asset by optimizing the use of its system resources.
VMs can also improve security, especially for testing experimental or high-risk applications. Testing these applications on VMs can be done quickly, and we can easily add or delete VM instances depending on how many applications must be tested at the moment.