AWS Builder Center
I Put a Game of Life to Sleep on AWS Lambda MicroVMs, and It Actually Stayed Asleep

I Put a Game of Life to Sleep on AWS Lambda MicroVMs, and It Actually Stayed Asleep

A Game of Life that hibernates on AWS Lambda MicroVMs. Suspend/resume timing, a live browser demo, and every bug I hit while testing it for real.

Cloud Engineer
AWS Lambda MicroVMs went GA on June 22, 2026. The pitch is straightforward: a dedicated Firecracker VM per session, up to 16 vCPUs and 32GB of memory, state preserved across suspend and resume, and up to 8 hours of runtime. It's aimed at things like AI coding sandboxes and interactive dev environments — code that needs to remember what it was doing between requests.
That's a reasonable, sensible use case. I wanted to do something less reasonable with it.
The feature that caught my attention wasn't the vCPU count or the memory ceiling. It was this line in the docs: while suspended, a MicroVM keeps its memory and disk state, and you pay only for snapshot storage — no compute charge at all. Which means you can take a running process, freeze it mid-thought, walk away for an hour, and come back to find it exactly where you left it, without paying a cent of compute for the time in between.
So I built a small universe that does nothing but tick forward, wired it up so that anyone visiting a page can watch it evolve, and let AWS put it to sleep whenever nobody's looking. Here's what happened when I actually tried to measure the "sleep" part instead of just trusting the docs.

What I built

The app itself is almost embarrassingly simple: a Conway's Game of Life simulation running inside the MicroVM, ticking every 400ms, broadcasting the grid over a WebSocket to whoever's connected. Click a cell, life appears. Nobody's watching, the idle policy suspends the whole VM after five minutes.
setInterval(step, TICK_MS);
That's the entire "engine." The interesting part isn't the Game of Life — it's what happens to that  setInterval  when the VM underneath it gets frozen and thawed.
I called the project Sleeping Universe. It's live at  sleeping-universe.vercel.app  if you want to poke at it — refresh, wait a couple hundred milliseconds for the wake-up, and click around.


Getting a MicroVM running

The CLI workflow is close to a normal Lambda: package your app with a Dockerfile into a zip, upload it to S3, and build an image.
aws lambda-microvms create-microvm-image \
--name sleeping-universe \
--code-artifact uri=s3://my-bucket/app.zip \
--base-image-arn arn:aws:lambda:ap-northeast-1:aws:microvm-image:al2023-1 \
--build-role-arn arn:aws:iam::<account>:role/MicrovmBuildRole
Then you run a MicroVM from that image, get back a dedicated HTTPS endpoint, and everything after that goes through it:
aws lambda-microvms run-microvm \
--image-identifier <image-arn> \
--idle-policy '{"autoResumeEnabled":true,"maxIdleDurationSeconds":300,"suspendedDurationSeconds":28800}'
This part mostly worked as documented, once I got past the small stuff — the getting-started guide uses a bare image name where the CLI actually wants the full ARN, and the IAM actions turned out to live under the  lambda:  namespace rather than  lambda-microvms: , which I only found out from an AccessDeniedException, not from reading anything first.

The part that isn't in the getting-started guide

Every request to a MicroVM needs an auth token, sent as an  X-aws-proxy-auth  header. Fine for curl. Not fine for a browser, which can't set arbitrary headers on a WebSocket connection — and a WebSocket is exactly what I needed for pushing grid updates in real time.
I went looking for how anyone's supposed to connect from a browser, found a page that described the answer, and wrote code against it. It didn't work — the socket closed immediately with code 1006. Turned out the summary I'd been working from had dropped two of the three required subprotocols. The actual shape is:
const protocols = [
"lambda-microvms",
"lambda-microvms.authentication." + token,
"lambda-microvms.port.8080",
];
const ws = new WebSocket(`wss://${endpoint}/ws`, protocols);
All three. Miss the base  lambda-microvms  protocol or the port one and it just closes on you with no useful error. Once I had the full list, it worked from a plain browser tab with zero AWS credentials anywhere near the client — which is what makes it possible to have a public demo page at all. The token itself still needs to come from somewhere with real AWS credentials, so I put a tiny Lambda function behind a Function URL whose only job is minting a 10-minute, single-port token and handing it to whoever asks.
That backend had its own small trap: Lambda Function URLs need both  lambda:InvokeFunctionUrl  and  lambda:InvokeFunction  permissions attached to be truly public. I only had the first one and got a 403 with no obvious explanation until I dug through the resource policy by hand.


Does it actually freeze, or does it just look frozen?

This was the part I actually cared about. Suspending is one API call:
aws lambda-microvms suspend-microvm --microvm-identifier <id>
And resuming happens automatically the moment traffic hits the endpoint again, if  autoResumeEnabled  is set. The question was whether the simulation's generation counter would actually stop advancing during that suspended window, or whether "suspended" was more of a billing abstraction than a real freeze.
First attempt at measuring this gave me numbers that made no sense. I'd suspend the VM, wait five minutes, wake it up, and find the generation counter had jumped by over 200 — as if it had kept ticking the whole time. I spent a while assuming I'd misunderstood how suspend works, until I checked which browser tabs I still had open and found one: a leftover demo page from earlier testing, sitting there with its WebSocket still connected, quietly reconnecting every time the connection dropped. Every reconnect was a fresh request hitting the endpoint, which is exactly the kind of traffic that triggers auto-resume. My own test harness was waking up the thing it was supposed to be measuring.
Closed the tab, reran the clean cases, and the numbers finally told a consistent story:
Suspend duration
Generations advanced
Expected if never suspended
5s
2
~13
60s
2
~150
300s
5
~750
600s
3
~1500
The generation counter barely moves regardless of how long the thing sits suspended. The small residual (2–5 generations) lines up with the roughly half-second window between calling  suspend-microvm  and the state actually flipping to  SUSPENDED  — not with the wall-clock time spent asleep. The VM isn't idling quietly in the background; the clock genuinely stops.
Resume latency — time from the first request hitting a suspended endpoint to getting a response back — stayed in the 600–1300ms range across all four durations, with no obvious relationship to how long it had been asleep:
5s → 668ms, 60s → 740ms, 300s → 793ms, 600s → 1302ms.
That last number is a bit of an outlier and this is one run per data point, not a proper benchmark, so I wouldn't read too much into the exact curve. But the range matches what the docs claim: resume cost depends on the size of the state being restored, not on how long it's been sitting there.
One thing I couldn't verify: whether suspended time is actually billed at zero. AWS's pricing page says compute charges stop entirely while suspended and you pay only for snapshot storage, but Cost Explorer has enough reporting lag that same-day usage never showed up while I was testing. I'm taking the documented pricing model at face value here rather than claiming I confirmed it myself.


A bug that wasn't a bug

Clicking a cell on the canvas is supposed to bring it to life. Mine kept vanishing within about a second of clicking. I checked the WebSocket message handler, checked the coordinate math, checked whether the click event was even firing — all fine. Then I remembered how Conway's Game of Life actually works: a lone live cell with zero neighbors dies on the very next tick. I'd been toggling isolated single cells, and they were dying exactly as they're supposed to. Not a bug, just me forgetting the rules of the thing I'd built. Fixed it by placing a 2x2 block instead of a single cell — a block is stable, since each cell in it has exactly three neighbors, so now a click leaves something you can actually see.

What's actually running

The public page is a completely static file — no build step, no server of its own. On load, it fetches a short-lived token from the Function URL, opens a WebSocket straight to the MicroVM using the subprotocol trick above, and renders whatever grid state comes back. If the universe was asleep, the first request wakes it and you'll see the "connected" line report however many milliseconds the wake-up took.
Try it at  sleeping-universe.vercel.app . If nobody's visited in five minutes, it's asleep right now, and your visit is what wakes it up.

Closing thoughts

MicroVMs are being pitched for AI agent sandboxes and coding assistants, which is a fair use case, but the property that's actually interesting is a much older idea wearing a new interface: cheap process hibernation, done properly, with the OS-level state (not just application state) coming back exactly as it left. Most of what took time here wasn't the AWS service itself — it was the usual pile of small things: a documentation example one command away from correct, a permission model with an undocumented second requirement, a stray browser tab that quietly invalidated an experiment. None of that is unique to MicroVMs. It's just what building on a two-month-old GA service looks like in practice.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article