What Is a Virtual Machine? When VMs Make Sense and When They Don’t

A practical guide to virtualization, hypervisors, and the real-world problems virtual machines solve.

Cloud Computing

A virtual machine (VM) is a software-based computer that runs inside another computer. A single physical computer lets you run multiple virtual machines. In fact, you can run multiple operating systems, like Windows and Linux, on a single physical machine. Virtual machines are commonly used for testing software, running older applications, and powering cloud services.

VMs are best when you need to run a full operating system in isolation, especially for strong workload separation, OS flexibility, or legacy compatibility. They are not the lightest or fastest way to run software, and they are usually the wrong default for lightweight, cloud-native application deployment where containers are a better fit.

How virtual machines turn one computer into many

A virtual machine relies on a hypervisor, which is software that allows one physical computer to host one or more virtual machines. When a VM is created, the user assigns it CPU, memory, storage, and other resources from the host. The guest operating system then consumes those assigned resources and behaves as though it were running on a physical device, while the hypervisor keeps each VM isolated and manages how host resources are shared.

What is a virtual machine and how virtual machines turn one computer into many
What is a virtual machine and how virtual machines turn one computer into many (Image Credit: Brien Posey/Petri.com)

Essentially, virtualization technology allows users to create and run multiple virtual machines simultaneously on a single host. For instance, a Windows host is capable of running different virtual machines with Windows, CentOS, Ubuntu, and other Linux distributions.

A virtual server uses hypervisor software to interact with the underlying physical hardware. It makes it possible to keep VMs separate and evenly allocate host resources (CPUs, storage, and memory) to each VM guest as needed. The hypervisor can also schedule operations to prevent deadlocks.

Choosing between type 1 and type 2 hypervisors

There are two primary types of hypervisors that are used in virtualization – Type 1 hypervisors and Type 2 hypervisors. While both are capable of hosting virtual machines, they work in two completely different ways

Why type 1 hypervisors dominate data centers

First up, a type 1 hypervisor, also called a bare-metal hypervisor, runs natively on the physical computer. This computer does not run a traditional operating system such as Windows or Linux. Instead, the hypervisor takes the place of the machine’s operating system.

Because there is no “real” operating system installed on the machine, Type 1 hypervisors typically require external management tools.  Type 1 hypervisors also typically deliver better performance and reliability and potentially better security than a Type 2 hypervisor, simply because the hypervisor lacks the overhead and attack surface of a traditional operating system. Some popular examples of popular Type 1 hypervisors include VMware ESXi, Citrix, and KVM.  

A type 2 hypervisor, also known as a hosted hypervisor, can run as an application on the host OS. It allows users to manually create a virtual machine instance and install a guest operating system.

The type 2 hypervisor is comparatively slower because each virtual machine request must be routed to the host operating system. It is suitable for individuals, developers, and small companies that can’t afford to purchase dedicated servers. Some common examples of type 2 hypervisors include Oracle VirtualBox and VMware Workstation Pro.

Virtualization is the technology that makes VMs possible

Virtualization is a technology that involves the creation of an abstraction layer over a physical host machine. It helps to divide hardware resources (CPU, RAM, and storage) of a single computer into different virtual computers called virtual machines.

Each virtual machine acts as an independent machine with its own operating system. It is a cost-effective solution for organizations that want to run multiple operating systems and applications on a single physical server.

Not all virtualization is about virtual machines

It is also worth separating virtual machines from virtualization as a broader category. VMs are the most familiar example, but virtualization can also apply to storage, networks, desktops, and other resources. That distinction matters because not every virtualization concept helps a beginner understand when to use a VM.

1. Hardware virtualization

Hardware virtualization, also known as server virtualization, is a technique that allows users to create virtual versions of computers and operating systems. It makes it possible to simultaneously run multiple operating systems on the same physical machine. Hardware virtualization also optimizes the utilization of hardware resources.

2. Software virtualization

Software virtualization is a method that enables a physical host machine to run multiple virtual computers. It leverages hypervisor software to distribute the hardware resources (such as storage, processors, and memory) among different virtual machines (VMs). For instance, a Linux distribution can be run in a virtual machine on a computer that is running a Windows operating system.

3. Storage virtualization

Storage virtualization consolidates the physical storage from multiple network storage devices to appear as a single virtual disk. It has various benefits including reduced costs, load balancing, disaster recovery planning, and improved performance and speed.

4. Network virtualization

Network virtualization is a process that is used to group physical networks into a single software-based virtual network. It helps to distribute the available bandwidth into various channels and allocate them to devices and servers. It offers benefits such as improved security, reliability, and network speed.

5. Desktop virtualization

Desktop virtualization enables users to simulate a workstation load so that it can be accessed from anywhere on any device. Its primary benefits include cost savings, resource optimization, enhanced data security, and easier management.

Why organizations still rely on virtual machines

VMs provide various benefits to both end-users and IT administrators. Here is a list of some of the features that make virtual machines very attractive in enterprise environments:

1. Cloud computing

Virtualization technology provides the basic architecture for cloud computing. It enables businesses to deploy and migrate cloud-native virtual machines to on-premises server environments and to leverage hybrid clouds.

It is also possible for organizations to allocate and change cloud resources in real-time to meet their dynamic usage requirements. Cloud-based VM services are popular for running SaaS applications, backing up data, and hosting email & access management services.

2. Cost efficiency

Virtual machines allow organizations to create and run multiple virtual machine instances on a single server. As IT hardware costs can be a real challenge for businesses, VMs can help increase cost efficiency by using minimum physical hardware resources. For example, IT admins can use a single server machine to deploy different applications in an enterprise environment.

The cost benefit of VMs is real, but it depends on disciplined resource allocation. Overcommitting CPU and memory can make consolidation look efficient on paper while creating performance problems that are harder to diagnose than on physical servers.

3. Security

Users can create virtual environments to boost security and prevent malware from impacting the underlying hardware and operating system. It is possible for users to quickly and easily revert a compromised VM to older versions in case of a cyber attack.

Meanwhile, developers can use VMs to test software updates and apps before releasing them to production users. VMs are also helpful for researchers to test malicious software.

4. Scalability and portability

Virtualization allows customers to rapidly deploy different types of VMs with the operating systems of their choice and a specific set of resources. VMs can also help organizations to better respond to variations in workloads. They can also save the extra time and effort required to install different operating systems on physical servers.

5. Workload migration

Virtual machines are referred to as “self-contained packages” that are decoupled from the physical computer. This makes it easier for IT teams to migrate to faster hardware, move a VM from one server to another, as well as recover from failures.

6. Disaster recovery

Organizations can use virtual machines to back up their systems in cloud environments. This capability provides an additional layer of security and minimizes the risk of data loss in scenarios such as hardware failures.

7. DevOps support

VMs provide maximum flexibility in supporting enterprise developers. They can create isolated environments with complete functionality for the software development and testing process. VMs also allow developers to run and test incompatible software on different operating systems.

VMs vs. containers: Which problem are you solving?

Just like virtual machines, containers make it possible to run applications that are isolated from the underlying host. However, let’s take a closer look at the major differences between virtual machines and containers:

Virtual MachinesContainers
Hardware-level process isolationOperating system-level process isolation
A virtual machine offers complete isolation of apps from the host OSContainers can share some resources with the host OS
VMs use a few GBs of system memoryContainers require less memory space (KBs or MBs)
Each VM has a dedicated OSContainers can share OS resources
VM is more secureContainers are less secure
Boots in minutesBoots in seconds
VMs consume more system resourcesContainers consume fewer resources
VMs can move between hardwareContainers are destroyed and recreated
VM creation takes a considerable amount of timeUsers can create containers within a few seconds
Users can run any OS inside the VMUsers can only run containers on the same OS version as the host
Some popular use cases of VMs are running multiple applications, monolithic applications, and legacy apps on older OS.Containers are best for running web apps, DevOps testing, and microservices.
Virtual machines vs containers

Virtual machines and containers are both mechanisms for running applications in isolated environments. However, they serve two different purposes and work in completely different ways.

A virtual machine is essentially a self-contained, software defined computer. It has everything that it needs in order to function as such. A virtual machine has its own dedicated hardware, operating system, files, and applications. The important thing to understand is that each virtual machine is self-contained and not directly dependent on other VMs that may be running on the host.

A container, on the other hand, does not contain its own operating system. Instead, a container shares the physical machine’s operating system. A container may store configuration files, application binaries, and files, but the core operating system is shared with the host. Because of this, containers tend to be very small and fast, and they start almost instantly. Containers also tend to consume fewer resources than a virtual machine.

Most VM performance problems start with resource allocation

Assuming a Type 1 hypervisor is being used, a VM can perform close to a physical machine, but only when the host has enough capacity and the workloads are sized realistically. Performance problems usually appear when administrators treat virtualization as free consolidation rather than shared infrastructure with real CPU, memory, storage, and network limits.

Enterprise cloud use of virtual machines

Virtual machines aren’t just used on servers that organizations own—they’re also the foundation of many cloud computing services. Instead of buying and maintaining physical hardware, you can rent a virtual machine from a cloud provider whenever you need one. Cloud providers such as Amazon Web Services (AWS) and Microsoft Azure let you choose the operating system, processing power, memory, and storage that best fit your needs, then create a virtual machine in minutes. On AWS, these virtual machines are called Amazon EC2 instances, while Microsoft Azure refers to them as Azure Virtual Machines. Although they run in a remote data center rather than on your own computer, they work much like any other virtual machine and give you full control over the operating system and applications you install.

The main use cases for virtual machines

Virtual machines have several use cases for both end-users and IT administrators. Here are a few examples:

1. Safely test new operating systems

Virtual machines enable users to run multiple operating systems on a single physical host. This means that users can test new features without affecting their primary operating system.

As an example, a Windows user might create a virtual machine in an effort to learn Linux. Similarly, when Microsoft makes Windows preview releases available, many people install these preview builds within virtual machines. This allows them to experiment with the preview release, without potentially jeopardizing their primary operating system.

2. Keep legacy applications running

Another common use case of virtual machines is the ability to use legacy software applications that are not supported by modern operating systems. As an example, gamers sometimes use DOS Box as a platform for running legacy DOS games, because those games are not compatible with modern operating systems.

3. Analyze malware without risking production devices

Malware researchers often need new machines to test malicious programs or applications. This is where virtual machines come in handy. Researchers can test malicious software in a VM rather than putting a physical computer at risk of infection.

4. Test software across multiple operating systems

Virtualization technology enables software developers and testers to test their applications across multiple platforms. For instance, a team of developers can use various virtual machines to test different versions of an app in various environments. As an example, a developer might wish to certify their application for use on Windows 10 and Windows 11. Virtualization would allow that developer to run both operating systems on the same computer, rather than using a separate computer for each.

5. Build disposable training environments

It is important for training room computers to run various instances of operating systems. Virtual machines let trainers conduct training sessions that replicate different business scenarios and environments.

6. Isolate risky browsing activity

Lastly, virtual machines can help to ensure a secure browsing experience for users. It is possible to take a snapshot of a VM in its current state and then roll it back in case of malware infection. Users can either set up a Type 2 hypervisor or ask an IT admin to grant them temporary access to a virtual desktop hosted on a server.

Choose a VM when the operating system matters

Use a VM when the operating system itself matters: testing Windows builds, isolating risky workloads, supporting legacy applications, or running server workloads that require full OS control. Do not choose VMs simply because they are familiar. If the workload only needs process isolation and fast deployment, containers may be the better default. The practical test is simple: if the operating system boundary matters, a VM is usually justified; if only the application matters, start by considering a container.

Frequently asked questions

What is a virtual machine in simple terms?

A virtual machine is a software defined computer that runs on top of a physical computer. A single physical host can simultaneously run multiple virtual machines, each of which function similarly to a physical computer. Every virtual machine has its own operating system, files, and applications.

What is the difference between a VM and a physical computer?

Physical and virtual machines are very similar to one another. They may run similar operating systems and similar applications. The main difference is that when a physical computer is used for hosting virtual machines that one physical machine can run multiple virtual machines. These virtual machines are isolated from the physical computer’s operating system and are functionally independent from one another.

What are virtual machines used for?

Virtual machines can serve any number of purposes. In a datacenter environment, virtual machines make it possible for a single physical computer to run multiple workloads, thereby distributing hardware costs across all of the virtual machines rather than each workload needing its own dedicated physical server.

Virtual machines are also commonly used for running alternative operating systems, investigating malware, or testing new software applications.

Are virtual machines safe?

Virtual machines are widely considered to be safe, because the hypervisor ensures that virtual machines are isolated from one another. The software that is running inside of a virtual machine is kept isolated from the hypervisor and from other virtual machines. However, virtual machines carry the same security risks as physical machines. Just as a physical computer can suffer a ransomware attack, so too can a virtual machine. In other words, virtual machines are safe, but only so long as you adhere to the usual security best practices.