← Blog2026-11-27
Resuming a paused sandbox: 155 ms for 1 GiB, under a second for 16 GiB
Pause and resume only works if resume is fast. We got a production resume to ~155 ms and a 16 GiB sandbox on a full host from 11 s to under a second — by recording which pages resume actually needs and serving each fault faster.
Pause and resume is what makes per-second billing honest: a paused sandbox keeps its memory, files and processes, and you pay only for the snapshot's storage. But the feature only exists if resume is fast — if waking a sandbox takes seconds, people leave them running and the whole point is gone. So we made resume fast twice over: the common case, a 1 GiB sandbox, resumes in ~155 ms in production; the worst case we test, a 16 GiB sandbox on a host that is already full, went from ~11 s to 0.5–0.9 s. Every number below is measured.
How a resume works
On pause, the guest's memory is written to a snapshot cache on the node. On resume, the VM starts running almost immediately while its pages stream back: the guest's RAM is registered with userfaultfd, each page the guest touches faults, and we serve that fault from the snapshot. This is also why the guest runs on ordinary 4 KiB pages — userfaultfd doesn't work on hugepages — so a resume is thousands of small page deliveries, and the game is making each one cheap and predictable.
Knowing which pages resume will need
Most of a guest's pages are never touched again after resume; guessing wrong wastes both time and cache bandwidth. After a pause, we run the snapshot once in a throwaway VM — a rehearsal — and record exactly which regions it accesses; resume then fills those regions ahead of the guest instead of waiting for each fault. A cousin of the same idea keeps a prefetch map per template build for newly created sandboxes — about 5,700 regions for the base template — but that's the next post's story.
Two refinements on the map: regions recorded as written are loaded writable, skipping the write-protect round trip entirely; and fills batch a window of neighboring pages — plus/minus 16 — because page use clusters. Resuming right after the rehearsal completes came down from ~322 ms to ~239 ms server-side; resume without a fresh rehearsal is ~40 ms slower, which is why the rehearsal runs in the background the moment a sandbox pauses.
Serving each fault faster
The remaining per-fault work was itself a bottleneck. A write-protect fault used to hand off to a fresh worker goroutine — on bare metal the kernel round trip is ~12 µs, but our Go scheduling pushed it to ~80 µs per fault. Parsing the common case inline in the serving loop brought it to ~18 µs (p50 48.7 → 17.8 µs measured), and anything contended still falls back to the worker path.
Memory pressure changes the problem again: when the node is full, the cache file itself is partly on disk and the copy-back competes with live guests. Three orchestrator changes handle that: the memory image copies from memfd to the cache file in the background while the guest still runs, so by resume time most of it is already local; pages not yet copied are served straight out of memfd instead of waiting for the copy; and when a batched fill abandons a page, every vCPU parked on it is woken — forget that and a vCPU sleeps forever. Each of those cases has a kernel-level regression test now. Together they took the 16 GiB resume from ~11 s to 0.5–0.9 s and post-resume read-back from ~25 MB/s to 240–270 MB/s.
What production measures
| Case | Number | Where measured |
|---|---|---|
| Resume a 1 GiB sandbox | p50 154–157 ms, p90 168–176 ms | Production, Singapore client, repeated runs |
| Resume a 16 GiB sandbox, node full | 0.5–0.9 s; ~11 s before the fixes | Bare-metal stress runs |
| Read-back after resume, 16 GiB | 240–270 MB/s; ~25 MB/s before | Same |
| Resume while neighbors over-allocate | p95 ≤ 2 s target; 2–4 s in the extreme phase | Stress runs, over-admission phase |
| Write-protect fault served | p50 ~18 µs; ~80 µs before | Node traces |
What's left
Resume is only half of felt speed — creating a fresh sandbox is the other half, and it has its own pipeline (disk pools, guest init, prefetch). That's a separate post. The create path is down to ~163–169 ms p50 in production and measured daily on our benchmarks page.