Hermes Wiki
Developer/Compute/VMs/Fundamentals/virtual-machines-and-the-hypervisor-isolation-boundary

Virtual Machines and the Hypervisor Isolation Boundary

Concept

A virtual machine virtualizes an entire computer — CPU, memory, disk, network interface — so that a guest operating system boots and runs believing it owns real hardware, when in fact a hypervisor is mediating every privileged instruction underneath it. The hypervisor comes in two shapes that matter for where a workload actually runs:

Type 1 (bare-metal) hypervisors — VMware ESXi, Microsoft Hyper-V, Xen, and the KVM module built into the Linux kernel — run directly on the host hardware with no general-purpose OS underneath them. This is what every public cloud VM (an EC2 instance, a GCE instance) is actually built on: the cloud provider's host runs a Type 1 hypervisor, and your VM is one guest among many sharing that physical machine. Type 2 (hosted) hypervisors — VirtualBox, VMware Workstation, Parallels — run as an application on top of an already-installed host OS (your laptop's macOS or Windows), which is simpler to install but adds a second scheduling and I/O layer between the guest and the hardware.

The isolation VMs provide is hardware-level: each guest gets its own virtualized CPU registers, page tables, and device models, enforced by CPU virtualization extensions (Intel VT-x, AMD-V) that trap privileged instructions the guest kernel tries to execute and let the hypervisor decide whether to honor them. This is a fundamentally different isolation boundary than a container's: a container shares the host's single kernel and is isolated by kernel-level namespaces and cgroups, while a VM's guest kernel is entirely its own, talking to virtualized hardware rather than to the host's real devices directly. That difference is the whole story behind every VM-vs-container tradeoff conversation.

Tradeoffs

Isolation model Benefit Cost
VM (Type 1 hypervisor, hardware virtualization) Strong isolation — a compromised or crashed guest kernel cannot touch the host kernel or other guests; guest can run a different OS/kernel than the host Boots a full OS per instance (seconds, not milliseconds); higher memory/disk overhead per instance; more moving parts to patch (guest kernel + hypervisor)
Container (shared host kernel, namespaces/cgroups) Starts in milliseconds; far lower memory overhead — hundreds of containers can share one host's kernel Weaker isolation boundary — a kernel-level exploit in one container can, in principle, affect the host or co-located containers; guest must use the host's kernel/OS family
MicroVM (Firecracker, gVisor) Near-VM isolation strength with near-container startup speed, by minimizing the virtualized device surface to what a single function actually needs Younger technology with a narrower device/driver surface; not a drop-in replacement for a general-purpose VM workload

The practical decision is rarely "VM or container" in the abstract — it's whether the workload's risk profile (multi-tenant, untrusted code, compliance boundary) justifies paying the VM's boot-time and resource cost for its stronger kernel-level isolation, or whether the workload is trusted enough, and needs to scale fast enough, that a container's shared-kernel model is an acceptable risk. AWS Lambda and Fargate's use of Firecracker microVMs under the hood is a direct answer to this tension: it gives multi-tenant serverless functions VM-grade isolation without paying a traditional VM's multi-second boot time.

When to use / when not to

  • Use a VM when the workload needs a specific OS, kernel version, or kernel module the host can't provide, or when running genuinely untrusted or multi-tenant code that needs a hard isolation boundary a shared kernel doesn't give you.
  • Use a VM for legacy software with hard dependencies on an old OS/runtime combination that can't be containerized without a rewrite.
  • Don't default to a VM for a stateless, trusted application service that could run as a container — you'll pay boot time, memory overhead, and patching burden for isolation strength the workload doesn't need.
  • Don't assume "it's in a VM" alone satisfies a compliance isolation requirement without checking whether the hypervisor itself (and its patch level) is in scope — the isolation boundary is only as strong as the hypervisor enforcing it.

Common pitfall

Treating VM and container isolation as interchangeable when reasoning about a security or compliance boundary. A container's isolation depends entirely on the host kernel correctly enforcing namespaces and cgroups for every co-located container; a kernel vulnerability (a known class, e.g. certain runc or cgroup escape CVEs) can let one container affect others or the host. A VM's isolation depends on the hypervisor and CPU virtualization extensions instead, a materially different and generally stronger trust boundary. Multi-tenant SaaS platforms that put genuinely untrusted customer code in a bare container next to other customers' workloads — rather than a VM or microVM — are making an isolation-strength tradeoff that is easy to overlook until an incident forces the question.

Engineering Lens

The VM-vs-container decision is really a question about where you want to place the isolation boundary, and every execution model on the spectrum — full VM, microVM, container, WASM sandbox — is a different answer to "how much of the OS/kernel gets shared, and what's the blast radius if that shared layer is compromised." The Principal-level framing in a design review isn't "VMs are heavyweight, containers are lightweight" as a blanket rule — it's naming the specific isolation guarantee a workload actually needs (kernel-level, hardware-level, or none) and picking the model that provides exactly that, rather than defaulting to whatever the team is most comfortable operating. Firecracker's rise inside AWS is the clearest evidence this isn't a binary choice: it exists because "VM-strength isolation" and "container-speed startup" used to be mutually exclusive, and closing that gap changed what multi-tenant serverless could safely offer.

Sources

Hermes Wiki