What is a MicroVM?
A microVM is a lightweight virtual machine that combines the security benefits of traditional VMs with the speed and resource efficiency of containers. SmolVM leverages microVMs to provide hardware-isolated sandboxes for AI agents and untrusted code execution.MicroVMs vs Containers
Think of the security difference this way:- Containers are like separate apartments in the same building—they share the same foundation (kernel) but have separate living spaces
- MicroVMs are like separate houses with their own foundations—each has its own kernel and complete isolation
Containers
- Share host kernel
- Process-level isolation
- Faster startup (~100ms)
- Smaller attack surface to host
MicroVMs
- Own guest kernel (KVM/HVF)
- Hardware virtualization
- Fast startup (~500ms)
- Strong isolation boundary
Why MicroVMs for AI Agents?
When AI agents generate and execute code, you need stronger isolation than containers provide:Isolation Layers
SmolVM provides multiple layers of defense:- Hardware Virtualization (KVM/HVF): Each VM runs with its own kernel in a separate memory space
- Minimal Attack Surface: Firecracker/QEMU are purpose-built with minimal device emulation
- Network Isolation: Dedicated TAP devices with firewall rules prevent VM-to-VM communication
- Ephemeral by Default: Fresh rootfs per VM means no state persistence between runs
Firecracker MicroVMs
SmolVM’s default backend on Linux is Firecracker, an open-source VMM (Virtual Machine Monitor) built by AWS specifically for serverless workloads.Key Characteristics
- Minimal Device Model: Only virtio devices (network, block, vsock)
- Fast Boot: Sub-second initialization through aggressive optimization
- KVM-Backed: Requires Linux with KVM support (
/dev/kvm) - Memory Efficient: ~5MB overhead per VM
- Designed for Multi-Tenancy: Used in production by AWS Lambda and Fargate
Architecture Overview
Communication Path
When you callvm.run("echo hello"), here’s what happens:
- SmolVM SDK sends SSH command over the network to
172.16.0.x:22 - TAP device (
tap-smol-xyz) routes packets from host to guest - Firecracker emulates virtio-net device and forwards to guest kernel
- Guest SSH server executes the command and returns output
- Response flows back through the same path to your Python code
Command execution latency is ~43ms (p50) after SSH is established, measured on AMD Ryzen 7 7800X3D.
Performance Characteristics
SmolVM is optimized for agent workflows with frequent create/destroy cycles:| Lifecycle Phase | Time (p50) |
|---|---|
| Create + Start | ~572ms |
| SSH Ready | ~2.1s |
| Command Execution | ~43ms |
| Stop + Delete | ~751ms |
| Full Lifecycle | ~3.5s |
Benchmarks from
scripts/benchmarks/bench_subprocess.py on Ubuntu Linux with KVM. macOS QEMU backend will have different characteristics.Memory and Disk Footprint
Default Configuration
- Memory: 512 MiB per VM (configurable via
mem_size_mib) - Disk: 1024 MiB per VM (configurable via
disk_size_mib) - Firecracker overhead: ~5 MB per VM process
- Host resources: Can run 100+ VMs on a modern workstation
Disk Isolation
SmolVM defaults to isolated disk mode (disk_mode="isolated"):
- Each VM gets a copy-on-write clone of the base rootfs image
- Changes are isolated per-VM and discarded on shutdown
- Prevents cross-contamination between agent sessions
Next Steps
Security Model
Learn about SmolVM’s security boundaries and SSH trust model
Networking
Deep dive into TAP devices, NAT, and port forwarding
Backends
Compare Firecracker and QEMU backends