Skip to main content
Running separate services on separate machines can be wasteful, and cramming everything onto one is a recipe for crashes. Virtual machines let a single physical computer safely host multiple independent systems.
The image features a person standing in front of a black background with a digital illustration of servers and gears, along with labeled buttons saying "Payroll," "Email," and "Backup." The person is wearing a shirt with the KodeKloud logo.
Imagine you have only one laptop, but need software that runs only on a different operating system. Cody is on a Mac while her client sends a Microsoft Access file — a Windows-only database app with no cloud version. Instead of buying hardware or replacing her OS, Cody runs a full Windows system inside her Mac. That contained Windows instance is a virtual machine (VM) — the core idea of virtualization.
The image shows a laptop with an icon labeled "VM" on the screen and a speech bubble with another laptop displaying a Windows logo. To the side, a man in a "KodeKloud" t-shirt stands with his hands clasped.
In this lesson you’ll learn how virtualization works, what a hypervisor does, and the trade-offs when running VMs versus other approaches. What is virtualization? Virtualization dates back to the 1960s when IBM used it on mainframes to run multiple logical systems on one physical machine. That approach evolved into modern server virtualization and powers cloud providers today.
The image features a person in a KodeKloud t-shirt standing next to an illustration of computer servers labeled "Virtualization 1960" with the IBM logo.
At a high level, virtualization is the practice of running multiple “guest” computers — virtual machines — on a single physical “host.” Each VM has its own operating system, applications, and configuration. The host provides physical CPU, memory, storage, and networking; a hypervisor divides these resources and presents them as virtual hardware to each guest.
The image displays a person standing next to a computer screen, which shows graphics labeled "Old Software" and "Risky Update" under the heading "VM," with logos of AWS and Google Cloud above. The person is wearing a KodeKloud T-shirt.
Cloud providers like AWS run many customers’ VMs on shared hardware. For example, multiple EC2 instances (VMs) from different customers can run on the same server while remaining logically isolated. This keeps cost down and allows efficient hardware utilization.
The image illustrates an AWS server diagram showing two websites, "Website 1" (Your Website) and "Website 2" (Friend's Website), connecting to a central server. A person wearing a "KodeKloud" shirt is standing to the right.
How virtualization works The usual stack is hardware → host OS/kernel → apps. Virtualization inserts a hypervisor layer that abstracts physical resources and exposes virtual hardware to each guest OS so multiple OSes can run concurrently on the same physical machine.
The image illustrates the concept of virtualization, showing a diagram with a hypervisor managing multiple operating systems on hardware and a person next to it speaking or explaining.
Hypervisor types There are two common classes of hypervisors:
Hypervisor TypeWhere it runsTypical use casesExamples
Type 1 (bare metal)Directly on hardware (no host OS)Data centers, cloud providers, production serversVMware ESXi, Microsoft Hyper-V, Xen, KVM
Type 2 (hosted)On top of an existing OSDesktop virtualization, development, testingVirtualBox, VMware Workstation, Parallels Desktop
Both types let each VM run a full guest OS on virtualized CPU, memory, storage, and network devices. Modern CPUs include virtualization extensions (Intel VT-x, AMD‑V) that reduce overhead and boost performance. Networking for VMs VMs are isolated by default, but they can communicate when configured. Common VM network modes and when to use them:
Network ModeDescriptionUse case
NAT (Network Address Translation)VM shares host’s network; outbound appears to come from hostSimple internet access for guest; safe default
BridgedVM gets its own IP on the physical networkRun a server inside the VM or simulate multiple devices
Host-onlyVM communicates only with host (and other host-only VMs)Secure local testing without internet access
The image illustrates a networking concept showing virtual machines (VMs) connected to a host and a router using a bridged connection. A person wearing a "KodeKloud" t-shirt gestures beside the diagram.
The image explains "Host Only" networking, illustrating how virtual machines (VMs) can communicate only with the host machine and not with the internet or other VMs. It also features a person wearing a KodeKloud shirt.
Security considerations VMs improve isolation — a crashed or compromised guest is usually contained — but isolation is not absolute. Pay attention to these risks:
  • Shared folders and clipboard integration can transfer malware between host and guest.
  • Misconfigured virtual networks can expose multiple VMs to threats.
  • Hypervisor vulnerabilities (rare) have enabled escapes where a malicious guest affects the host.
When testing untrusted software, disconnect the VM from networks and disable shared folders/clipboard. Keep hypervisors and guest OSes up to date to minimize escape risks.
Performance and resource trade-offs Virtualization improves hardware utilization but adds overhead. Key trade-offs:
  • Each VM runs a full OS, so VMs consume more RAM and disk and boot more slowly than containers.
  • Over-provisioning CPU or memory across several VMs can degrade performance for all guests and the host.
  • Standard VMs may not have direct GPU access; GPU passthrough or specialized virtualization is required for graphics- or ML-heavy workloads.
Start with modest resource allocations, monitor metrics, and scale allocations as needed. Flexibility and common uses VMs are highly flexible: run different OSes on the same hardware, preserve legacy environments, or create reproducible lab environments for testing upgrades and cross-platform builds. Snapshots and cloning Most VM platforms support snapshots (point-in-time captures of disk and memory) and cloning:
  • Snapshots let you revert a VM to a prior state quickly — great for testing risky changes.
  • Cloning creates full copies for labs or reproducible environments.
Snapshots are convenient for testing, but they are not a substitute for backups. Snapshots can depend on parent disks and grow over time, so manage and consolidate them carefully.
The image shows a person explaining virtual machine concepts, featuring icons and text related to VMware, VirtualBox, and taking snapshots to save VM states.
Quick check Which of the following statements is true? A. A VM runs directly on the hardware with no OS.
B. A hypervisor lets one computer run multiple VMs.
C. VMs are isolated, so they can’t communicate with each other.
The image shows a multiple-choice question about virtual machines, highlighting three statements, and a person speaking on the right side.
Answer: B is true.
  • A is incorrect — even with Type 1 hypervisors you still run guest OSes inside VMs.
  • C is incorrect — VMs are isolated by default, but they can communicate when networking is configured (bridged, NAT with port forwarding, or internal virtual networks).
Recap
  • A virtual machine is a virtualized computer running inside a physical host with its own guest OS and apps.
  • A hypervisor creates and manages VMs by partitioning hardware resources.
  • Type 1 hypervisors run on bare metal; Type 2 hypervisors run on top of a host OS.
  • VMs provide flexibility and strong isolation but are heavier than containers and have higher resource overhead.
  • Snapshots and cloning simplify testing and labs, but snapshots are not a replacement for proper backups.
The image features a graphic of a cube with "VM" written on it, highlighting benefits like flexibility, isolation, and suitability for testing, alongside a person wearing a KodeKloud t-shirt.
Each VM needs a full OS, which means slower startups and higher resource consumption compared to lighter alternatives. When you need lower overhead and faster startups, consider containers — they address many of the performance and resource trade-offs of traditional virtualization. Further reading and references

Watch Video