What is a virtual machine?

A virtual machine (VM) is a software-based computer that provides an isolated environment on host hardware. Virtual machines can run programs and operating systems, store data, connect to networks, and do other computing functions. Much of the technology we benefit from today, such as cloud computing and artificial intelligence, is rooted in the concept of the virtual machine, which allows operating systems and software to be separated from a physical machine. For instance, VMs in cloud computing are used to virtualize the resources of cloud service providers’ servers, enabling the multi-tenant cloud architecture that allows customers to share resources while being isolated from one another.

How do virtual machines work?

Virtual machines use virtualization technology to create virtual hardware—or a virtual version of a computer on a physical machine. The physical machine on which the VMs run is called the host, and the VMs running on the host are called guests

Each guest VM runs on an isolated partition on the host, completely separated from other guests. You can host multiple VMs on a single host machine, often a server, running on a software layer known as the hypervisor.

The hypervisor abstracts the host machine’s physical resources, such as CPUs, GPUs, TPUs, memory, storage, or networks, into a pool that can be provisioned and dynamically allocated to guest VMs as needed, providing more flexibility and increasing overall efficiency.

Two main types of hypervisors

  • Type 1: bare-metal hypervisors: These run directly on the host's physical hardware. They're commonly used in enterprise data centers for their high performance and efficiency. For example, Google Cloud uses a KVM-based hypervisor to power its Compute Engine virtual machines.
  • Type 2: hosted hypervisors: These run as an application on top of an existing operating system, making them suitable for desktop use. The most common use case for these is for development and testing.

Types of virtual machines

Generally speaking, there are two types of virtual machines: process VMs and system VMs.

A process VM, also called an application virtual machine or managed runtime environment (MRE), creates a virtual environment of an OS while an app or single process is running and destroys it as soon as you exit. Process VMs enable creating a platform-independent environment that lets an app or process run the same way on any platform. A concrete example of this is the Node.js runtime on App Engine, which allows a Node.js program to run in a managed environment on Google Cloud, regardless of the underlying operating system.

A system VM (sometimes called hardware virtual machines) simulates a complete operating system, allowing multiple OS environments to live on the same machine. Typically, this is the type of VM people are referring to when they talk about “virtual machines.” System VMs can run their own OS and applications, and a hypervisor monitors and distributes the physical host machine’s resources between system VMs.

Some cloud providers, including Google, offer the additional ability to customize the exact amount of virtual processors and virtual memory in each instance. This enables more precise “right sizing” for each workload and avoids underutilization and the associated resource and software license costs for that compute instance. For example, some workloads may require a high compute core to memory ratio, while others may require the opposite. Customization of the virtual machine addresses these use cases without overprovisioning and overpaying for resources that will not be utilized.

VMs vs. Containers

While both VMs and containers are used to isolate applications, they do it in fundamentally different ways. A virtual machine virtualizes the entire physical hardware stack, including the operating system. This makes each VM a self-contained, isolated environment, but it also means that VMs tend to be larger and take up more resources.

By contrast, containers are more lightweight because they virtualize only the OS layer. Instead of bundling a full operating system with each application, a container shares the host's OS kernel. This enables containers to use fewer resources than VMs and start up faster while remaining isolated. This makes containers attractive for new application development. Since many of the applications developed over the last 10 years were written for containers, many workloads including e-commerce, back-office, and AI are “container native.

How are virtual machines used?

VMs are the basic building blocks of virtualized computing resources and play a primary role in creating any application, tool, or environment—both in the cloud or on-premises.

Here are a few of the more common ways businesses use virtual machines:

Multiple physical machines can be reconfigured as a VM and run on a host alongside other VMs, allowing organizations to reduce sprawl. VMs have been proven over time to be capable of running even the most performance sensitive applications.

A central IT organization can provision and manage VMs for each business unit and functional area, speeding access to resources while improving corporate visibility.

VMs can serve as isolated environments for testing and development that include full functionality but have no impact on the surrounding infrastructure.

VMs can easily be turned off or on, migrated, and adapted, providing maximum flexibility for development and deployment.

The flexibility and portability that VMs provide are key to increasing the velocity of migration initiatives.

Replicating systems in cloud environments using VMs can provide an extra layer of security and certainty. Cloud environments can also be continuously updated.

VMs provide the foundation for creating a cloud environment alongside an on-premises one, bringing flexibility without abandoning legacy systems.

Benefits of virtual machines

Virtual machines offer many benefits, particularly if you opt for a cloud VM, including the following: 

Scalability

Cloud-based VMs make it easier to scale your applications, increasing availability and performance. You can increase your capacity according to demand without having to invest in your own physical servers. 

Portability 

A virtual machine is a single software package with hardware resources, an operating system, and all its applications. You can easily move VMs from one server to another, or even from on-premises hardware into cloud environments. 

Reduced footprint and costs

VMs allow you to run multiple virtual environments from a single machine, helping reduce your physical infrastructure footprint, electricity bill, and maintenance and management costs. 

Faster provisioning 

VMs can be easily duplicated, enabling businesses to spin up new, identical environments without having to set them up from scratch.

Reliability

Virtual machines and their components exist virtually and remain isolated from other guest VMs. If VM crashes, the other guest VMs will remain operational, and the physical host machine won't be affected. 

Better security

Virtual machines allow you to run multiple operating systems without impacting the host operating system. VMs let you create safe, virtual  environments to test apps or even study security vulnerabilities without high risk to the host machine. 

Potential challenges of virtual machines

There are, however, some considerations to keep in mind when running VMs. One of the biggest potential challenges of virtual machines is that running multiple operating systems and a hypervisor layer can come with a performance cost if the host machine isn’t robust enough. In addition, virtual hardware may not be as efficient as the physical hardware of a physical machine. Finally, most cloud providers offer virtual machines that are fixed in the CPU and memory they provide, leading to inefficient usage of resources.

Many of these concerns though can be overcome by choosing to use VMs offered by a cloud service provider. Cloud VMs provide many advantages over traditional VMs since they offer organizations access to the computing power of an entire data center’s worth of computers, rather than a single machine. In addition, Google Compute Engine virtual machines sizes offer custom machine types. Rather than selecting from predefined machine types that might include excess capacity, you can tailor the CPU-to-memory ratio specifically for your workloads, so you only pay for resources you actually use. This targeted approach minimizes waste and can significantly reduce your cloud spend, especially when migrating from on-premises to Google Cloud or from other cloud providers. Compute Engine also delivers virtual machine types optimized for specific customer needs for enterprise workloads, high memory configurations, or demanding workloads like machine learning or high performance computing.

Google Cloud also offers shielded virtual machines for extra security and verifiable integrity of your VM instances. Google Cloud shielded virtual machines leverage advanced platform security capabilities and controls that protect enterprise workloads from threats like remote attacks, privilege escalation, and malicious insiders. 

Solve your business challenges with Google Cloud

New customers get $300 in free credits to spend on Google Cloud.
Talk to a Google Cloud sales specialist to discuss your unique challenge in more detail.

Take the next step

Start building on Google Cloud with $300 in free credits and 20+ always free products.

Google Cloud