CLOUD & INFRASTRUCTURE / SYSTEM CONCEPT BRIEF

Virtualization

Virtualization lets one physical machine run many isolated virtual machines, each with its own operating system, by placing a hypervisor between hardware and guests.

BeginnerPhase 07 / Topic 9 of 17RequirementsTrade-offsFailure modes
01

Overview

Virtualization lets one physical machine run many isolated virtual machines, each with its own operating system, by placing a hypervisor between hardware and guests. The hypervisor divides CPU, memory, storage, and network among VMs and prevents them from interfering with each other. It is the foundation that made cloud computing possible.

Type 1 hypervisors run directly on hardware (KVM, VMware ESXi, Xen, Hyper-V); Type 2 run on a host OS (VirtualBox). Modern CPUs have hardware support (Intel VT-x, AMD-V) and cloud providers offload networking and storage to dedicated hardware (AWS Nitro) so VMs run at near-native speed.

Apartments in a building

One building (physical server) is divided into apartments (VMs), each with its own locks, kitchen, and utilities meter. The building manager (hypervisor) allocates space and keeps tenants from entering each other's homes.

02

When to use it

  • Running multiple OSes or strongly isolated workloads on shared hardware.
  • Cloud infrastructure (every EC2 instance is a VM).
  • Legacy applications that need a full OS.
  • Security isolation stronger than containers.
03

Where it shows up in interviews

Isolation choice

Recognize it when: containers or VMs for untrusted code?

  • Design a code execution sandbox (LeetCode runner)
  • Design a multi-tenant hosting platform
04

Where it is used in real software

AWS Nitro

Custom hardware and a lightweight hypervisor give EC2 near bare-metal performance and strong isolation.

Firecracker

AWS's microVM monitor starts VMs in ~125 ms; it powers Lambda and Fargate.

VMware in enterprises

Most enterprise data centers virtualize servers with vSphere or Hyper-V.

05

Key terms

Hypervisor
Software that creates and runs VMs.
Type 1 / Type 2
Bare-metal / hosted hypervisor.
Guest / host
Virtual machine OS / physical machine.
Overcommit
Allocating more virtual resources than physical ones.
MicroVM
Minimal VM optimized for fast startup and density.
06

How it works, step by step

  1. 1
    Hypervisor boots on hardware

    Controls CPU virtualization extensions.

  2. 2
    VMs are created

    With virtual CPUs, memory, disks, and NICs.

  3. 3
    Guest OS boots

    Believes it has its own hardware.

  4. 4
    Hypervisor schedules

    Maps vCPUs to physical cores and isolates memory.

  5. 5
    Live migration (optional)

    Move running VMs between hosts for maintenance.

07

Isolation technologies

From strongest isolation to lightest

Step 1 / 5
TechnologyIsolationStartupOverhead
Bare metalPhysicalMinutesNone
Virtual machineHardware-virtualized kernelTens of secondsLow-moderate
MicroVM (Firecracker)VM-level~125 msVery low
Sandboxed container (gVisor)User-space kernel~SecondsModerate for syscalls
ContainerNamespaces and cgroupsmsMinimal

NOWTechnology: Bare metal | Isolation: Physical | Startup: Minutes | Overhead: None

Running untrusted code (serverless, online judges) usually uses microVMs or sandboxes for safety with near-container speed.

08

Implementation

resource "aws_instance" "worker" {  ami                    = data.aws_ami.al2023_arm.id  instance_type          = "m7g.large"   # 2 vCPU, 8 GiB, Graviton (ARM)  subnet_id              = aws_subnet.private_a.id  vpc_security_group_ids = [aws_security_group.worker.id]  metadata_options { http_tokens = "required" } # IMDSv2 only   root_block_device {    volume_type = "gp3"    volume_size = 30    encrypted   = true  }  tags = { Name = "worker", team = "platform" }}
09

Complexity and performance

CPU overhead~0-5%

With hardware virtualization.

Firecracker boot~125 ms

Thousands per host.

10

Trade-offs

Isolation vs density

VMs isolate strongly but use more memory and boot slower than containers.

Overcommit vs performance

Overcommitting improves utilization but can cause noisy neighbors.

11

Variants and related techniques

Paravirtualization

Guests use hypervisor-aware drivers for efficiency (virtio).

Nested virtualization

VMs inside VMs, used for testing and some CI.

12

Common mistakes

  • Treating VMs as pets.

    Fix: Build immutable images and replace VMs instead of patching by hand.

  • Using containers alone for untrusted code.

    Fix: Add microVM or sandbox isolation.

13

Interview questions

How would you run untrusted user code safely?

Execute it in short-lived microVMs (Firecracker) or sandboxed containers (gVisor) with no network by default, strict CPU, memory, and time limits, read-only filesystems, and destroy them after each run.

What is a hypervisor?

Software that virtualizes hardware so multiple isolated guest operating systems share one physical machine, scheduling CPU and isolating memory, storage, and network.

14

Practice problems

ProblemDifficultyWhat it trains
Compare VM and container isolation for a SaaSEasyTrade-offs.
Design an online code execution serviceHardSandboxing and scaling.