How to Run Firecracker MicroVMs on EC2 and Launch Browsers in Under 1 Second — Programming article on gikiewicz.com

AWS introduced Firecracker in 2018 as the virtualization engine behind AWS Lambda and AWS Fargate. The open-source project now powers isolation for workloads where milliseconds matter. Infrastructure teams run Firecracker on EC2 bare-metal instances to launch isolated browser environments at scale.

TL;DR: Firecracker microVMs can boot in less than 125 milliseconds, allowing infrastructure teams to spin up isolated browser environments on EC2 instances dynamically. AWS reports that properly configured EBS burst credits are essential for maintaining these sub-second startup times during high-density scaling events.

What Is Firecracker and Why Run It on EC2?

Firecracker is a virtualization monitor built in Rust by AWS, designed specifically for multi-tenant container and function workloads. The project’s GitHub repository documents a minimal device model that excludes legacy hardware emulation, resulting in a tiny attack surface. The Firecracker binary itself is approximately 5 MB, and the project enforces strict security boundaries through seccomp filters and jailers. This matters for browser isolation.

Running Firecracker on EC2 gives teams direct access to Nitro hardware without the overhead of nested virtualization. Bare-metal instances like m5n.metal and m6i.metal expose the full CPU instruction set, including KVM support required by Firecracker. Teams deploying browser farms on EC2 benefit from predictable networking performance and direct EBS attachment. AWS documents that EBS volumes attached to Nitro-based instances can achieve burst performance of up to 3,000 IOPS on gp2 volumes and sustained throughput that depends heavily on credit accumulation.

Why choose Firecracker over traditional containers? The answer is isolation strength. Each microVM runs its own kernel, completely separating workloads from the host. This matters for untrusted browser content.

The trade-off involves density. A standard Docker container adds near-zero overhead, while each Firecracker microVM consumes dedicated memory for its guest kernel. Teams must balance security requirements against per-instance consolidation ratios when planning deployments.

How Does Firecracker Achieve Sub-Second Virtual Machine Boot Times?

Firecracker’s boot performance stems from deliberate architectural decisions documented in the project’s design papers. The virtual machine manager strips out all unnecessary device emulation, supporting only virtio-net, virtio-block, virtio-console, and a serial port. This minimalism matters. Traditional QEMU-based VMs emulate dozens of legacy devices during boot.

The project’s GitHub documentation reports boot times of 125 ms for a microVM running a stripped-down Linux kernel. This figure assumes a pre-loaded kernel image and root filesystem already resident in memory. For browser automation workloads, teams typically pre-bake a root filesystem containing Chromium or Firefox binaries, then snapshot the running microVM for rapid restoration.

Firecracker supports two mechanisms that enable sub-second cold starts. First, the API supports copy-on-write memory mapping, allowing multiple microVMs to share a single base memory image. Second, the snapshot restore API can resume a paused microVM from disk in under 10 ms when the snapshot file resides on a high-performance EBS volume.

AWS documentation notes that EBS gp3 volumes provide baseline performance of 3,000 IOPS and 125 MB/s throughput at no additional cost. This baseline is sufficient for snapshot restoration. During burst scaling events, however, teams must monitor credit balances carefully to avoid throttling.

What EC2 Instance Types Work Best for Hosting Firecracker MicroVMs?

Bare-metal EC2 instances are the only viable option for running Firecracker, because the virtualization monitor requires direct access to KVM. AWS publishes a complete list of Nitro-based bare-metal instances in the EC2 documentation. The most commonly used families include m5.metal, m6i.metal, and c6i.metal, each offering different ratios of vCPU to memory.

For browser automation workloads, memory capacity typically becomes the binding constraint. A single Chromium instance with multiple tabs can consume 500 MB to 2 GB of RAM depending on page complexity. On an m5.metal instance with 96 vCPUs and 384 GB of memory, teams can realistically run 40 to 60 concurrent Firecracker microVMs, each allocated 4 to 8 GB.

Instance TypevCPUsMemoryMax MicroVMsHourly Cost
m5.metal96384 GB40-60$3.912
m6i.metal128512 GB55-75$5.232
c6i.metal128256 GB25-35$4.608
m6a.metal192768 GB80-110$4.896

Cost optimization depends on workload patterns. Teams running batch browser jobs can use Spot pricing on bare-metal instances, though availability fluctuates. For always-on browser farms, Savings Plans reduce m6i.metal costs by up to 72% compared to on-demand rates.

The choice between AMD and Intel variants affects performance. AMD-based m6a.metal instances offer higher core counts at lower hourly rates, while Intel m6i.metal instances provide slightly better single-thread performance for JavaScript-heavy pages.

How Do You Configure the Network Bridge for Firecracker on EC2?

Firecracker microVMs require a TAP device on the host for network connectivity, connected to a Linux bridge that routes traffic to the instance’s primary network interface. On EC2, this requires disabling source and destination checks on the primary ENI and configuring the bridge with the instance’s private IP address.

The setup process involves several discrete steps. First, create a Linux bridge interface named br0 and attach the primary ENI (eth0) to it. Second, create a TAP device for each microVM using ip tuntap add. Third, attach each TAP device to the bridge. Fourth, configure DHCP or static addressing inside each microVM’s root filesystem.

# Create the bridge
ip link add br0 type bridge
ip link set eth0 master br0
ip link set br0 up

# Create a TAP device for a microVM
ip tuntap add tap0 mode tap user root
ip link set tap0 master br0
ip link set tap0 up

# Disable checksum offloading on TAP
ethtool -K tap0 tx off

Firecracker’s API configuration requires specifying the TAP device name in the network interface definition. The microVM’s kernel receives an IP address via DHCP from dnsmasq running on the host, or through static configuration baked into the root filesystem image. AWS security groups apply to traffic at the ENI level, so all microVM traffic passes through the instance’s assigned security group rules.

For outbound internet access from microVMs, enable IP masquerading on the host using iptables or nftables. The POSTROUTING chain must include a masquerade rule for the bridge subnet. This setup allows each microVM to appear as a single source IP to external services, which is sufficient for most browser automation scenarios.

AWS imposes a soft limit of 50 TAP devices per instance through default network interface quotas. Teams needing higher density can request quota increases, but performance degradation may occur beyond 100 concurrent TAP devices due to kernel bridge processing overhead.

What Is the Fastest Way to Provision a Browser Inside a MicroVM?

The fastest way to provision a browser inside a Firecracker microVM is to pre-bake the browser binary into the root filesystem image and use a snapshot restore mechanism. Firecracker supports restoring from a snapshot in approximately 125 milliseconds, according to AWS documentation on microVM performance. This eliminates the need to install the browser at runtime.

Pre-baking the root filesystem means the browser binary, all required shared libraries, and configuration files are already present when the microVM boots. The only remaining task is to launch the browser process. This approach reduces provisioning time to well under one second. The key optimization is avoiding package managers entirely.

Snapshot restore works by saving the memory state of a running microVM to disk. When a new session is needed, Firecracker loads that memory state directly instead of performing a full boot sequence. The process skips kernel initialization, driver loading, and service startup. This is why cold starts drop dramatically.

For browser workloads specifically, the root filesystem image should contain a minimal Linux distribution, the headless browser binary (such as Chromium or Firefox), and any required display libraries. Stripping unnecessary packages keeps the image small. Smaller images load faster from EBS storage.

Developers typically create a base snapshot once, after booting the microVM and initializing the browser process in a suspended state. Each new request then restores from that snapshot and resumes execution. The browser is already loaded in memory. Only the specific page navigation remains.

Configuration tuning also affects provisioning speed. Firecracker allows setting the number of vCPUs and the amount of RAM allocated to each microVM. For a single headless browser instance, one vCPU and 512 MB of RAM are usually sufficient. Allocating more resources than necessary wastes host capacity without improving performance.

Network configuration should use a pre-configured tap device on the host. Creating network interfaces dynamically adds latency to the provisioning process. By preparing tap devices in advance and assigning them to microVMs at restore time, network setup becomes nearly instantaneous.

The following list summarizes the key steps for fast browser provisioning:

  • Create a minimal root filesystem with the browser binary pre-installed
  • Boot a microVM and initialize the browser process in a suspended state
  • Save a snapshot of the microVM memory state to disk
  • Pre-configure tap network devices on the host EC2 instance
  • On each request, restore the microVM from the snapshot file
  • Resume the browser process and navigate to the target URL
  • Avoid running package managers or download steps at runtime
  • Keep the root filesystem image under 500 MB for fast EBS reads

How Do EBS Burst Credits Impact MicroVM Density on EC2?

EBS burst credits directly determine how many microVMs can be provisioned simultaneously on a single EC2 host. According to the AWS compute blog on simulating EBS burst credits, gp2 volumes accumulate credits at a rate of 3 IOPS per GB per second of provisioned storage. When burst credits are exhausted, volume performance drops to baseline levels.

This matters because restoring Firecracker snapshots requires reading large files from EBS. Each snapshot file contains the full memory state of the microVM, often 256 MB or more. If dozens of microVMs are restored at the same time, the EBS volume must serve thousands of IOPS. Without sufficient burst credits, restore times increase from milliseconds to seconds.

The AWS blog post describes a methodology for simulating EBS burst credit behavior before downsizing an instance. This simulation helps predict whether a smaller EBS volume can sustain the expected workload. Running the simulation prevents production incidents caused by unexpected credit depletion. The tooling provided by AWS models credit consumption based on actual I/O patterns.

For high-density microVM deployments, the recommended approach is to use larger gp2 volumes or provisioned IOPS (io1 or io2) volumes. A 1 TB gp2 volume provides 3,000 baseline IOPS, which is enough to handle concurrent snapshot restores for dozens of microVMs. Smaller volumes risk credit exhaustion during traffic spikes.

Another factor is the burst bucket size. The maximum number of credits a gp2 volume can accumulate depends on its size. Larger volumes have bigger buckets and can sustain burst performance for longer periods. This directly affects how many microVMs can be launched in a short window.

Monitoring EBS credit balance is essential. The CloudWatch metric BurstBalance shows the remaining burst credits as a percentage. When this metric drops below 20%, restore times begin to degrade. Setting alarms on this metric prevents unexpected slowdowns.

The following table compares EBS volume types for microVM workloads:

Volume TypeSizeBaseline IOPSMax Burst IOPSBest For
gp2100 GB3003,000Low-density testing
gp21 TB3,0003,000Medium-density production
gp3100 GB3,00016,000High-density production
io2100 GBconfigurable64,000Maximum performance

How Does Firecracker Compare to Docker for Browser Isolation?

Firecracker provides stronger isolation than Docker because each microVM runs a separate Linux kernel. Docker containers share the host kernel, which means a kernel exploit or a container escape vulnerability can compromise all containers on the host. Firecracker uses KVM-based virtualization with a minimal device model, reducing the attack surface significantly.

The trade-off is resource overhead. Docker containers typically consume less memory because they share kernel space. Firecracker microVMs each require their own kernel memory allocation. However, Firecracker was designed specifically for high-density workloads, and its memory overhead is approximately 5 MB per microVM, which is far lower than traditional virtual machines.

Startup time is another major difference. Docker containers can start in one to two seconds when images are already pulled. Firecracker microVMs boot from a kernel image in approximately 125 milliseconds. When using snapshot restore, the effective startup time drops even further. This makes Firecracker faster for workloads that require frequent provisioning.

For browser isolation specifically, the security boundary matters. Running untrusted web content in a Docker container provides process-level isolation. Running it in a Firecracker microVM provides hardware-level isolation via nested paging and KVM. If a browser exploit gains code execution, the attacker is confined to the microVM kernel, not the host kernel.

Docker offers greater flexibility in terms of image management and orchestration. Tools like Docker Compose and Kubernetes have mature ecosystems for container scheduling. Firecracker has a simpler API but lacks built-in orchestration. Teams must build their own scheduling layer or use frameworks like Firecracker Containerd.

The following list highlights the main differences:

  • Firecracker uses KVM virtualization; Docker uses Linux namespaces and cgroups
  • Each Firecracker microVM has its own kernel; Docker containers share the host kernel
  • Firecracker boots in ~125 ms; Docker containers start in 1-2 seconds
  • Firecracker memory overhead is ~5 MB per VM; Docker overhead is lower
  • Firecracker provides hardware-level isolation; Docker provides process-level isolation
  • Docker has mature orchestration tools; Firecracker requires custom scheduling
  • Firecracker is purpose-built for serverless workloads; Docker is general-purpose
  • Snapshot restore in Firecracker is faster than Docker image layer caching

What Are the Security Boundaries When Nesting VMs on EC2?

Running Firecracker microVMs inside an EC2 instance creates a nested virtualization boundary. The EC2 instance itself is a VM running on a Nitro hypervisor. Firecracker then uses KVM to launch microVMs inside that EC2 instance. This means there are two layers of hardware virtualization between the browser process and the physical CPU.

AWS Nitro provides the first security boundary. The Nitro hypervisor isolates EC2 instances from each other and from the underlying hardware. Firecracker adds a second boundary by using KVM to isolate microVMs from each other within the EC2 instance. This dual-boundary approach means an attacker who escapes the browser still faces two independent isolation layers.

Not all EC2 instance types support nested virtualization. Only bare metal instances (such as m5.metal) and certain instance types expose the underlying hardware directly, allowing KVM acceleration. On standard virtualized instances, Firecracker falls back to software emulation, which is significantly slower. Choosing the right instance type is critical for performance.

The Firecracker device model is intentionally minimal. It exposes only four virtual devices: a virtio-net device, a virtio-block device, a serial console, and a keyboard controller. This minimalism reduces the attack surface compared to full virtualization platforms like QEMU. Fewer devices mean fewer potential vulnerabilities.

Firecracker also runs in a seccomp sandbox that restricts the system calls available to the VMM process. Combined with jailer, a companion tool that sets up chroot environments and drops privileges, the Firecracker process itself is hardened against exploitation. Even if the VMM is compromised, the attacker cannot access the host filesystem directly.

For browser isolation workloads, the security model is as follows. Untrusted JavaScript runs inside the browser process. The browser runs inside a Firecracker microVM. The microVM runs inside an EC2 instance. The EC2 instance runs on a Nitro hypervisor. Each layer provides an independent security boundary.

How Should You Monitor Firecracker Performance in Production?

Monitoring Firecracker in production requires tracking metrics at three levels: the host EC2 instance, the Firecracker VMM process, and the individual microVMs. Firecracker exposes metrics through an API endpoint that can be polled periodically. These metrics include CPU usage, memory allocation, network throughput, and block device I/O for each microVM.

At the host level, standard CloudWatch metrics provide visibility into EC2 instance performance. Key metrics to watch include CPU utilization, network I/O, and EBS read/write operations. High CPU utilization combined with slow microVM provisioning indicates that the host is overcommitted. EBS metrics reveal whether storage is the bottleneck.

Firecracker’s built-in metrics are exported in JSON format and include detailed counters. The metrics cover virtio device operations, API call latency, and VMM lifecycle events. Teams should ingest these metrics into a monitoring system like Prometheus or Datadog. Setting up dashboards that correlate host-level metrics with microVM-level metrics helps identify performance regressions quickly.

The following list outlines the critical metrics to monitor:

  • Host CPU utilization (CloudWatch metric CPUUtilization)
  • Host memory usage (requires the CloudWatch agent)
  • EBS burst credit balance (CloudWatch metric BurstBalance)
  • EBS read/write IOPS (CloudWatch metrics VolumeReadOps and VolumeWriteOps)
  • Network throughput on the EC2 instance (CloudWatch metric NetworkIn and NetworkOut)
  • Firecracker API server latency (from Firecracker metrics endpoint)
  • Per-microVM CPU and memory usage (from Firecracker metrics)
  • Snapshot restore latency (custom metric from application logs)

Frequently Asked Questions

Can you run Firecracker inside a standard Docker container on EC2?

No, Firecracker requires access to the /dev/kvm device, which is not available inside a standard Docker container without privileged mode. Running a container with --privileged and mapping /dev/kvm into the container can work on bare metal EC2 instances. However, this approach weakens the container isolation that Docker provides.

How much RAM does a single Firecracker microVM running a headless browser require?

A single Firecracker microVM running a headless Chromium instance typically requires 512 MB of allocated RAM, plus approximately 5 MB of overhead for the Firecracker VMM process itself. The root filesystem image and kernel are shared across microVMs and do not count against per-VM memory. Running multiple tabs or heavy pages may require 1 GB or more.

Does nesting Firecracker microVMs violate any AWS terms of service?

No, running nested virtualization on AWS EC2 does not violate the terms of service when using supported instance types. Bare metal instances like m5.metal and i3.metal provide direct hardware access and are explicitly designed for nested virtualization workloads. AWS documentation confirms that Firecracker is supported on these instance types.

What is the maximum number of Firecracker microVMs you can run on a single EC2 host?

The maximum number depends on the EC2 instance size and the memory allocated per microVM. On an m5.metal instance with 96 vCPUs and 384 GB of RAM, allocating 512 MB per microVM allows approximately 750 concurrent microVMs. CPU overcommit ratios of 2:1 to 4:1 are common for browser workloads that are idle most of the time.

Summary

  • Firecracker microVMs boot in approximately 125 milliseconds, making sub-second browser provisioning achievable through snapshot restore and pre-baked root filesystems.
  • EBS burst credits are a critical bottleneck for high-density deployments. Use gp3 or io2 volumes and monitor the BurstBalance CloudWatch metric to prevent provisioning degradation.
  • Firecracker provides hardware-level isolation via KVM, offering stronger security boundaries than Docker containers for running untrusted browser content.
  • Only bare metal EC2 instances support KVM acceleration for nested Firecracker workloads. Standard virtualized instances fall back to slow software emulation.
  • Production monitoring should span three layers: CloudWatch for the EC2 host, Firecracker’s metrics API for microVM-level data, and custom metrics for snapshot restore latency.

If you are building a browser isolation platform or running untrusted workloads at scale, Firecracker on EC2 bare metal instances offers an unmatched combination of startup speed and security isolation. Start with a single m5.metal instance, pre-bake your root filesystem, and measure your snapshot restore times before scaling.