Cloud & Infrastructure · Paper 05 / 05

Firecracker: Lightweight Virtualization for Serverless Applications

Alexandru Agache, Marc Brooker, Andreea Florescu, Alexandra Iordache, Anthony Liguori, Rolf Neugebauer, Phil Piwonka, Diana-Maria Popa

2020 · NSDI · ~11 min read

Read the original paper

Serverless needs thousands of strangers' functions on one machine, isolated like virtual machines and starting like processes. Firecracker is the small VM that made both true.

The problem: thousands of strangers on one machine

A serverless platform promises to run your function the moment it is called and to charge you only while it runs. To make that pay, the provider must pack thousands of functions from thousands of unrelated customers onto each physical host, start a new one in a fraction of a second, and guarantee that none of them can read, interfere with or even time-attack another. The two existing tools each failed one requirement. Containers are dense and start in milliseconds but share the host kernel, and the Linux kernel’s attack surface is too large to bet a multi-tenant business on. Virtual machines isolate properly, with hardware help, but a conventional VM carries a full device model and firmware, costs hundreds of megabytes and takes seconds to boot.

containeryour functionruntimehost kernel · sharedhardwarevirtual machineyour functionguest kernelQEMU · 1.4M lines, BIOS, PCIKVM · hardwareFirecracker microVMyour functionguest kernelVMM · ~50k lines, 5 devicesKVM · hardwarehighlighted: the layer that decides the attack surface between tenants
Where the boundary lies. A container’s neighbours are one kernel bug away; a VM puts hardware between them but drags a million lines of device emulation along; a microVM keeps the hardware boundary and sheds the baggage.

The idea: a virtual machine with everything unnecessary removed

AWS Lambda had launched on containers inside dedicated per-customer VMs, which worked and wasted machines. Firecracker is the replacement: a virtual machine monitor that uses the Linux kernel’s KVM for the hardware boundary and implements only what a serverless function needs. No BIOS, no PCI bus, no USB, no graphics; a virtual network device, a block device, a serial console, a keyboard that exists only to signal reboot, and a small configuration API. Written in Rust, forked from Chrome OS’s crosvm, it is around fifty thousand lines where QEMU is well over a million.

How it works

A microVM boots an unmodified Linux kernel in about 125 milliseconds and adds under five megabytes of memory overhead, which is what lets a host run thousands of them; the paper reports creating up to 150 microVMs per second on one host. Memory and CPU are oversubscribed on purpose, since most functions idle most of the time, with rate limiters on network and disk so one tenant cannot starve the others.

Try itHow many strangers fit on one machine?

Pick a host size and a function's memory. Density is what fits; the race is a cold start, drawn to scale.

sandboxisolationmemory overheadcold startfunctions per host
traditional VMhardware (hypervisor)~512 MB~8000 ms204
containershared kernel (namespaces)~8 MB~60 ms963
Firecracker microVMhardware (KVM) + minimal device model~5 MB~125 ms985
traditional VMcontainerFirecracker microVMbars fill in real time; the long one is the point
density gain vs VMs4.8×more functions per host at this size
start-up gain vs VMs64×faster cold start

Containers were already dense and fast, but they share the host kernel with every other tenant; a provider cannot put strangers' code there. Virtual machines isolate properly but cost hundreds of megabytes and seconds to start. Firecracker keeps the hardware boundary and throws away everything a serverless function will never use: no BIOS, no PCI bus, five devices, and a 50,000-line VMM instead of a million.

The hardware boundary is not the only one. The VMM runs inside a jailer that drops it into fresh namespaces, a chroot and cgroups, removes its privileges, and applies a seccomp filter so the process can make only a short list of system calls. An attacker who escapes the guest kernel and then the VMM still finds themselves in a jail with nothing to use. The paper calls this defence in depth and treats it as the design rather than an extra.

host · KVM provides the hardware boundaryjailer: new namespaces, chroot, cgroups, dropped privilegesseccomp: the VMM may make ~24 system calls, nothing elseFirecracker VMM (Rust) → guest kernel → your functiondefence in depth: an escape from the guest still lands in a jail
The jailer. KVM provides the hardware boundary; the VMM process is additionally confined by seccomp, a chroot, namespaces and cgroups, so a breach has to cross several walls.

On top of the microVM, Lambda’s architecture keeps warm microVMs in slots on worker hosts, routes an invocation to an existing slot for that function if one is free, and otherwise creates one; later work added snapshot-and-restore so that a “cold” start can resume a pre-initialised memory image rather than booting at all.

What it changed

Firecracker made hardware-isolated sandboxes cheap enough to be the default, and AWS open-sourced it in 2018, before the paper. It runs Lambda and Fargate, and outside AWS it powers Fly.io’s machines, container runtimes such as Kata Containers, and the sandboxes that code-execution and AI-agent products use to run untrusted code. The broader lesson, that the right unit of isolation for the cloud is a stripped-down VM rather than a hardened container, reshaped how providers think about multi-tenancy.

Where you meet it today

  • AWS Lambda and Fargate. Every invocation runs in a Firecracker microVM.
  • Sandboxes for untrusted code. CI runners, online IDEs and AI coding agents increasingly execute inside microVMs rather than containers.
  • Kata Containers and friends. Kubernetes pods that are secretly tiny VMs.
  • The “cold start” conversation. The 125 ms figure, and snapshot-restore to beat it, define what serverless latency means.