Module 11 · Lesson 87 of 107

Boot time, density and where microVMs run

Explain microVM startup and memory costs, estimate host density, and choose a VMM for a production workload.

  • Beginner to advanced
  • 9 min read
  • 10 min lab
What you will need

Ubuntu 24.04 in WSL2 or a VM for the written exercises. No KVM access or physical board is required.

Your place in the module
By the end you can 4 objectives
  • Identify the boot stages that a direct-boot microVM skips.
  • Calculate a memory-limited guest count from a host budget and a per-guest footprint.
  • Choose Firecracker or Cloud Hypervisor from a workload's device requirements.
  • Explain how Firecracker and Kata provide VM isolation for function and container workloads.
Video coming soonBoot time, density and where microVMs run
The video for this lesson is being recorded. Read the lesson below in the meantime.
Recall first from The rust-vmm crates
  • kvm-bindings describes the KVM ABI, kvm-ioctls wraps calls to it, and vm-memory provides access to guest RAM.
  • virtio-queue handles split-ring bookkeeping while the VMM implements transport, device behavior, and interrupt delivery.
  • A vhost-user backend can process guest buffers in shared memory while the VMM owns the guest-facing device.
01

Why a microVM starts quickly

3 min read

The last lesson covered the crates. This lesson answers the boot-time and memory story, the device-model tradeoffs, and where AWS Lambda and Kata use microVMs in production.

AWS built Firecracker for services such as Lambda, where a request can arrive when there is no initialized execution environment available to serve it. Creating an isolated environment is then on the request's startup path. That is a concrete reason to shorten VM boot. The Firecracker paper describes the constraints AWS faced and the design it deployed. Firecracker, USENIX NSDI

A conventional PC-style boot typically begins in firmware. The firmware initializes the virtual platform and selects a boot target, then a bootloader loads the operating system. Firecracker can start with a Linux kernel image supplied by the operator. The VMM places the kernel and the required boot information in guest memory, sets the initial CPU state according to the architecture's boot protocol, and starts the vCPU. That removes the BIOS or full UEFI firmware phase and the separate disk bootloader phase. Linux still initializes its own kernel, discovers the provided devices, mounts its root filesystem and starts userspace.

The small device model reduces work on both sides. The VMM has fewer devices to create, and the kernel has fewer virtual devices to discover and initialize. In a simple setup, a virtual block device supplies the root filesystem and a virtual network device supplies connectivity. A kernel built for that known configuration, with the required drivers available early, can reach userspace quickly. The application then starts under a small guest init or runtime that carries out the setup the workload actually needs.

Direct Linux bootCreate VMRAM, vCPUsandselecteddevicesLoad Linuxdirectlykernel andbootinformationInitializeguestdrivers,rootfilesystemand initServerequestsapplicationinitializationcompleteCreate VMRAM, vCPUsandselecteddevicesLoad Linuxdirectlykernel andbootinformationInitializeguestdrivers,rootfilesystemand initServerequestsapplicationinitializationcomplete
The direct Linux boot path from VM creation to a ready workload

A tuned Firecracker configuration can boot on the order of 100 milliseconds. Treat that figure as a scale for a lean configuration with a defined measurement endpoint. A service's cold start may also include preparing a root filesystem, allocating networking, starting the application runtime, and loading application code. Those operations can dominate the time a caller sees even when the guest kernel starts quickly. If a guest reaches init before the application accepts a request, the init timestamp measures an earlier milestone.

For a useful comparison, start the clock at the same event for each configuration and stop it at the same observable event. For example, measure from VM launch to an application readiness response, and record an init milestone separately when you need to locate a delay. Use the same guest image and workload when comparing VMMs. Repeated launches under representative host load help show whether time is going into VM startup or into work that happens after the guest has begun running.

02

What sets memory use and density

3 min read

A lean Linux guest can fit in tens of megabytes when its kernel, userspace and workload are small. Keep two quantities separate when you plan capacity. Configured guest RAM is the memory the VM presents to Linux. The host footprint is the physical memory cost of running the instance under the conditions you measure. Guest pages that have become resident contribute to it, as do VMM allocations, device queues, and associated host kernel or backend allocations. A VMM overhead figure on its own gives you only one component of that cost.

Inside the guest, Linux needs space for its kernel and internal allocations. Guest processes need space for their code and data. Filesystem data can occupy cache, and a workload can allocate more memory as it handles requests. A guest that just finished booting may therefore have a smaller host footprint than the same guest after sustained activity. When a VMM maps guest RAM into its own address space, the populated pages can already appear in the VMM process's resident memory. Adding all configured guest RAM to that process's resident figure can count the same memory twice. Conversely, some host costs may sit outside that process.

Host memory consumersHost reservehost OS and shared servicesResident guest pagesguest kernel, applications and cacheVMM allocationsmemory outside the guest mappingHost-side supportkernel and backend allocationsHost reservehost OS and shared servicesResident guest pagesguest kernel, applicationsand cacheVMM allocationsmemory outside the guestmappingHost-side supportkernel and backendallocations
What the host memory budget must cover before you can estimate guest count

starts with a budget. Reserve memory for the host and the services that must run alongside the guests. Divide the remaining budget by the representative per-guest host footprint, expressed in the same units, and round down. If the footprint doubles with the available budget fixed, roughly half as many guests fit by memory. This gives a ceiling under those assumptions. Available CPU time, storage throughput or network capacity can set a lower ceiling.

Choosing a smaller RAM setting gives more room for instances only if it reduces their host cost while preserving the required behavior. A guest that fits at idle may run out of memory when the application allocates its peak working set. Cache reclaim can also increase I/O and slow responses before any allocation fails. Compare memory and latency under load, and include concurrent startup if the service starts many guests together. That is when temporary allocations can raise host demand across a group of VMs.

Near-container density is most plausible when similar workloads use small guest kernels and userspace, with little VMM overhead per instance. Each isolated VM still incurs its own guest kernel and VM state. If the application needs a large working set, or if each guest brings up many supporting services, the small device model accounts for less of the total memory bill. Measure the number of workload instances that fit at the required service level, since one VM may contain several cooperating containers.

Going deeperWhat Firecracker snapshots restore

A Firecracker snapshot can preserve an initialized guest for later restore. With the VM paused at capture, the snapshot records VM state, including vCPU and virtual device state, and saves guest memory. A full snapshot captures the memory image. A differential snapshot saves changed memory pages and requires the matching prior memory contents as a base. KVM dirty tracking lets Firecracker identify guest pages written since the previous tracking interval so it can avoid writing the entire memory image again.

Restore loads the saved VM state and supplies memory from the snapshot. The guest resumes from the captured execution point, so it can skip kernel boot and any application initialization already completed there. The saved memory and VM state depend on compatible disk contents and host resources. For example, the VM snapshot does not copy the backing block files, and a connection to an external peer may have expired while the guest was paused. Measure through application readiness after restore. Reading snapshot pages and reestablishing external resources can still contribute to latency.

03

Which devices and deployments fit

4 min read

Firecracker is a good fit when you control the guest image and can express its I/O through a small virtual device set. A short-lived worker that reads a root filesystem, talks over a virtual network interface, and optionally uses virtio-vsock for guest-to-host communication fits that design. By default Firecracker provides virtio block, network and vsock devices over virtio-mmio, with no PCI bus for assigning host hardware. Recent Firecracker releases can start with the --enable-pci flag, and their VFIO passthrough is documented as a Developer Preview feature, so check the release you run before relying on it. Keeping the exposed device interfaces small also limits the amount of guest-facing device code needed for that workload.

Choose Cloud Hypervisor when the guest needs a broader virtual platform or needs to own a compatible physical PCI function. For example, a workload that must use a PCI accelerator through its Linux guest driver can use Cloud Hypervisor's VFIO passthrough on a suitably configured host. The host must support and configure the IOMMU and be able to assign the device at the isolation granularity it exposes. The guest also needs the appropriate driver. That choice affects placement because each host must have an assignable device or function available. Guest driver initialization and the selected devices also become factors in startup and memory measurements.

Device requirements by VMMFirecrackerCloudHypervisorVirtual I/OSmall virtiodevice setBroadervirtualdeviceoptionsPCI deviceassignmentVFIO only asa DeveloperPreviewVFIO onsuitablehostsExample workloadShort-livednetworkworkerGuest usingPCIaccelerator
How the guest's device requirements guide the VMM choice
Going deeperWhich exits the minimal device set changes

A VM exit transfers control from the guest to the hypervisor. Some exits are handled in KVM, and some return control to the userspace VMM. A minimal device set removes accesses to devices the guest would otherwise probe or use. In a virtio workload, ordinary data descriptors sit in shared guest memory. The guest can submit multiple requests before notifying the backend, so the number of notifications depends on batching and guest behavior. KVM's ioeventfd can signal a backend for a registered write without returning that I/O operation to the userspace vCPU loop. The backend still has work to do.

Expect the device-related profile to change with the workload. Boot can involve device discovery and configuration accesses, while steady-state network and disk activity can produce virtqueue notifications and interrupt activity. CPU-related exits can still occur with a small device model. If you investigate latency, distinguish hardware exits, returns to the VMM, and time spent handling requests in the backend. Each count describes a different cost.

Firecracker supplies VM isolation in AWS Lambda and AWS Fargate. Lambda customers deploy function code, and Fargate customers deploy containers through a managed compute service. In both cases, AWS operates the host and the VMM. The separate guest kernel and the hardware-backed VM boundary let AWS run workloads from different customers on shared servers. Low per-VM memory costs help make that isolation practical at high instance counts.

Kata Containers addresses the deployment problem from the container runtime side. In Kubernetes, you can select Kata for a pod through a configured runtime class. Kata starts a VM for the pod sandbox and runs the pod's containers inside it, so cooperating containers in one pod can share a guest kernel. Kata has also been integrated with OpenStack deployments to run VM-isolated container workloads. Kata manages the container lifecycle and delegates VM execution to a configured VMM. When calculating memory and density, count the guest kernels at the sandbox boundary and the application processes inside each sandbox.

For both managed functions and VM-backed pods, the economics depend on how many sandboxes fit at the required latency and throughput. The same choice of isolation unit also determines which workloads share a guest kernel. Millisecond-scale timing alone cannot answer either question. Define where isolation is required, identify the devices that each isolated unit needs, then use the startup and memory costs of that unit in the capacity estimate.

The next lesson, Cockpit consolidation on one SoC, asks how to place workloads on a single embedded chip when they have different isolation and device requirements. It follows from the same decision about which workloads share a guest and which devices each guest can use.

Key takeaways

  • Direct Linux boot and a small device model let a tuned microVM start in roughly a tenth of a second.
  • A lean guest can run in tens of megabytes, and host capacity also depends on VMM and backend memory.
  • Firecracker suits workloads served by a small virtual device set, while Cloud Hypervisor supports assigning PCI devices through VFIO (Firecracker's own VFIO passthrough is a Developer Preview feature).
  • Firecracker underpins AWS Lambda and Fargate, while Kata integrates VM-backed container isolation with platforms such as Kubernetes and OpenStack.
Reflect
  1. Explain to a colleague, in two sentences: identify the boot stages that a direct-boot microVM skips.
  2. Which objective are you least sure about? Re-read that section, then do its exercise in the practice pack.
  3. What surprised you when you ran the commands yourself?
On a real board

Repeat the key commands on your Raspberry Pi or lab board over SSH or the serial console. Note anything that behaves differently from your PC, such as missing tools, a BusyBox shell or a read-only filesystem.

References and further reading

Find your next step

↑ ↓ to move · Enter to open · Esc to close