Firecracker microVMs: how AWS runs untrusted code in tiny VMs that boot in 125 ms
What is Firecracker? Firecracker is a virtual machine monitor that AWS wrote in Rust and open-sourced in 2018 under Apache 2.0. It started as a fork of Google's crosvm. It uses KVM in the Linux kernel to run small VMs called microVMs. AWS Lambda and Fargate run customer code inside them. A container is fast, but every container shares the host kernel, so one kernel bug can reach them all. A classic QEMU VM gives a hardware wall but carries a BIOS, USB, PCI and hundreds of devices. Firecracker keeps the VM wall and drops almost everything else: a microVM reaches user space in about 125 ms and costs under 5 MiB of extra memory.
One process per VM:
Every microVM is a single firecracker process. Its fc_api thread serves a REST API on a unix socket, the fc_vmm thread runs an epoll loop that emulates the devices, and one fc_vcpu thread per virtual CPU sits in a loop on ioctl(KVM_RUN). Guest RAM is plain mmap memory inside that process. Kill the process and the VM is gone.
How it boots and runs:
You configure the VM over the socket (PUT /machine-config, /boot-source, /drives, /network-interfaces), then send InstanceStart. There is no BIOS and no bootloader: Firecracker loads the uncompressed vmlinux into guest memory, sets the registers and jumps to the entry point. The guest runs at native speed until it touches a device address, which causes a VM exit such as KVM_EXIT_MMIO. Firecracker emulates the access and calls KVM_RUN again. Disk and network use virtio queues in shared memory, and ioeventfd / irqfd let KVM signal the VMM thread without a full exit for every kick. The whole device list is virtio-net, virtio-block, vsock, balloon, virtio-rng, a serial console and an i8042 stub for reset.
How it stays locked in:
An escape must beat four walls. KVM hardware virtualisation is the first. Seccomp is the second: each thread has its own BPF allow-list, and any other syscall kills the process. The jailer is the third: it creates new mount, PID and network namespaces, applies cgroups, chroots into /srv/jailer/firecracker/<id>/root and drops to an unprivileged uid before it starts Firecracker. A hardened host with SMT off is the last wall.
Snapshots and clones:
Pause a VM with PATCH /vm, write a vmstate file and a memory file with PUT /snapshot/create, then restore it anywhere with PUT /snapshot/load. The memory file is mapped MAP_PRIVATE, so pages load lazily and copy on write. The gotcha: every clone of one snapshot starts with the same RNG state and the same MAC address. Re-seed each clone.
Want the long version, from plain words down to KVM exits and virtio rings, with diagrams that draw themselves? Read the full Firecracker blog post.
Pages 2 and 3 of the book are below. Download the full 3-page PDF, free.