Choice 05. By Nicolas Dao · Last reviewed

Cloudflare Sandbox or Lambda MicroVMs?

My product runs code nobody reviewed, written by an LLM or a customer. Where does it run safely, and which fits which business?

Cloudflare Sandbox by default: a ready-made toolkit for running code, billed on active CPU, about a quarter of the price for short bursts. Lambda MicroVMs as soon as the code must run in Australia, reach a private VPC, use more than 4 vCPU, or keep its running processes through long sessions. Sandbox isn't in Pulumi yet: a small custom provider (about 3–5 days) or wrangler wrapped in Pulumi closes the gap.

When to pick which

Pick Cloudflare Sandbox when

  • Code runs in short bursts: a data-analysis chat running Python on a user's spreadsheet, a code interpreter in a SaaS feature.
  • The product is on Workers, and neither Australian residency nor a private VPC is required.
  • You want the toolkit ready: run commands and code, files, a terminal, preview URLs, backup and restore.

Pick Lambda MicroVMs when

  • The data must stay in Australia: MicroVMs run in Sydney, and Cloudflare can't pin a container there.
  • The code reads private data in a VPC, such as the client's Postgres.
  • Long sessions whose running processes must survive the user leaving: a coding agent's dev server, a build.
  • More than 4 vCPU or 12 GiB, or a government client that needs the work inside its AWS account.

Pick Neither when

  • The code is yours and reviewed, even if an agent wrote it: a Lambda, a Worker or a Fargate task is enough.

Both, when

  • Not in one product without a reason: two runtimes to build and maintain. Across a portfolio, yes: Sandbox for the products on Workers, MicroVMs for the clients who need Australia or their VPC.
  • One product can justify both when an enterprise tenant requires Australian residency: Sandbox for everyone else, MicroVMs for that tenant, if the tenant pays for the second runtime.

Questions that change the answer

  • Who wrote the code that will run? If it's your team, reviewed, you don't need a sandbox.

  • Must the code or the data stay in Australia? Then it's Lambda MicroVMs.

  • Does the code need private data in a VPC? Then it's Lambda MicroVMs.

  • How long is a session, and must its running processes survive a pause? Seconds to minutes points to Sandbox, hours with a running dev server to MicroVMs.

  • Must everything be provisioned with Pulumi today? MicroVMs are; Sandbox needs a small custom provider or a wrapped wrangler.

Do you need a sandbox at all?

Only when your product runs code that nobody on your team reviewed: code an LLM writes at runtime, or code a customer uploads. That code must never run where your credentials live. A normal Lambda runs with its function's role and environment variables, and its /tmp survives into the next invocation; hardening it into a sandbox is a project in itself.

If the code is yours, written by Claude Code on a laptop and reviewed before it ships, you need neither of these. A Lambda, a Worker or a Fargate task does the job.

The short version

Cloudflare Sandbox Lambda MicroVMs
My verdict Use when it fits: my default for this job Watching
What you get A toolkit, driven from a Worker through an SDK: run commands, Python and JavaScript, files, a terminal, preview URLs, backup and restore A raw isolated server: your own app in a Firecracker VM, reached through an HTTPS endpoint (HTTP/2, gRPC, WebSocket). No exec SDK: you build the server inside
Isolation A container per session A Firecracker microVM per instance
State Files, through backup and restore Memory and disk: suspends when idle and resumes on the next request with its processes running, for up to 8 hours in all
Sizes 1/16 vCPU and 256 MiB up to 4 vCPU, 12 GiB and 20 GB of disk 1 vCPU and 2 GB up to 16 vCPU, 32 GB and 32 GB of disk
CPU architecture amd64 Arm64
Billing Active CPU, plus the memory and disk you provision while it runs A baseline, every second it runs, busy or idle; suspended, only the snapshot
Network Outbound through a Worker that adds credentials per destination, so the code never sees them Public internet or your VPC, through a network connector
Where Cloudflare's network; can't be pinned to Australia Sydney, since August 2026
Pulumi Partly: the container attaches to a Worker in the Cloudflare provider; the image and the container application go through wrangler Official, in @pulumi/aws
Scale Per account: 1,500 vCPU, 6 TiB of memory and 30 TB of disk running at once Quotas not published

Priced: two real cases

Rates: Sandbox $0.000020 per active vCPU-second, $0.0000025 per GiB-second of memory and $0.00000007 per GB-second of disk, plus Workers Paid at $5 a month. MicroVMs at AWS's US East Arm rates, $0.0000276944 per vCPU-second and $0.0000036667 per GB-second, so the 1 vCPU / 2 GB baseline is about $0.126 a running hour; snapshots $0.0038 per GB written and $0.00155 per GB read. Free allowances left out (under $1). Egress not included.

A data-analysis chat: 50,000 sessions a month, each open 5 minutes, 20 seconds of CPU on 1 vCPU.

Per session Per month
Sandbox (1 vCPU, 3 GiB, 8 GB of disk) CPU $0.0004 + memory $0.00225 + disk $0.00017 = $0.0028 about $141, plus $5
MicroVMs (1 vCPU, 2 GB, stopped at the end) 300 seconds at the baseline: $0.0105 about $525

Sandbox is about 3.7 times cheaper. Suspending the MicroVM between a user's questions doesn't help: one suspend and resume of a 3 GB snapshot costs about $0.016, more than the session's compute.

A coding agent: 500 sessions a month at 2 vCPU and 8 GB, each 3 hours: one hour of work with the CPU half busy, then two hours with the user away.

Per session Per month
Sandbox, left running so its processes survive CPU $0.072 + memory $0.216 + disk $0.012 = $0.30 about $150
Sandbox, stopped while the user is away (files restored, processes lost) $0.15 about $74
MicroVMs, suspended while the user is away (memory and processes kept) active hour about $0.31 + one suspend and resume of about 10 GB, $0.05 = $0.36 about $180
MicroVMs, left running $0.56 about $280

Here they're close: Sandbox is cheaper if losing the running processes is acceptable, and MicroVMs cost about 20% more to bring the user back to the same running dev server, in Sydney, inside the VPC. The MicroVM figures assume the resources above the baseline are billed only while used, as AWS describes them; the exact metering isn't published in detail.

Which one, for which business

  • "Ask your data" in a SaaS product: Sandbox. A user uploads a spreadsheet and asks which region's sales dropped; the model writes Python, runs it on the file and returns a chart. Seconds per run, thousands of users, idle in between: Sandbox's runCode and file handling are already there, and you pay only while the code is on the CPU.
  • An AI coding agent on a real repository: MicroVMs. An internal agent that clones a client's repository, installs dependencies, runs the tests and starts a dev server for review, or an "AI builds your app" product. Sessions last hours and the user leaves for lunch: the VM suspends with node_modules, the dev server and its memory intact, and resumes as if nothing happened.
  • Customer-written rules in an enterprise platform: MicroVMs. An IoT platform where each client writes its own alert rules or transforms on its sensor data, a learning platform grading the code students submit, a rules engine running customers' scripts. The code reads that tenant's data in the private Postgres, and the data stays in Australia: only MicroVMs do both.
  • Opening untrusted files: MicroVMs. Scanning uploaded binaries or opening suspicious documents deserves a full VM's isolation, inside the AWS account with the rest of the security tooling.

Cloudflare Sandbox in Pulumi

Pulumi and Terraform providers are wrappers around a vendor's web API, and Cloudflare documents a Containers API (container applications, their image and instance type, rollouts, and registry credentials). Wrangler uses the same API: it fetches a 15-minute registry login, pushes the image to registry.cloudflare.com, creates or updates the container application and starts a rollout. Nobody has wrapped it yet: Pulumi has no roadmap item, and a pull request adding a container resource to Cloudflare's Terraform provider was closed unmerged in March 2026.

Option Effort What you get
A command resource running wrangler deploy, keyed on a hash of the source Half a day to a day It works, but Pulumi can't see what's deployed (no drift detection), and the machine running it needs Docker
A small TypeScript provider of our own (a Pulumi dynamic provider) for the application, plus @pulumi/docker-build for the image About 3–5 days Real Pulumi resources: create, update, delete and drift detection against the API, the image pinned by its digest, alongside the Cloudflare provider that attaches the container to the Worker
A full provider in Go 1–2 weeks, plus maintenance Only worth it to publish for others

I'd build the second the first time a client project needs Sandbox, and drop it the day Cloudflare ships an official resource. Part of the rollout API wrangler calls isn't fully documented, so it's ours to maintain until then.

What still forces Lambda MicroVMs

A client needs Cloudflare Sandbox Lambda MicroVMs
The data to stay in Australia Blocked. Containers offer only the eu, us and fedramp jurisdictions, and Oceania is "limited capacity" that can't be used on its own without dedicated access from Cloudflare's support Sydney
Access to a private VPC Only through the Worker's outbound handler, which carries HTTP. Cloudflare's private-network product (Workers VPC) is in beta and doesn't mention containers; a direct database connection from the container isn't confirmed Native, through a network connector
More than 4 vCPU or 12 GiB Blocked: 4 vCPU, 12 GiB and 20 GB of disk at most Up to 16 vCPU and 32 GB
Government work under IRAP Cloudflare's Australian assessment lists Workers, R2 and Durable Objects, not Containers (not confirmed) Not confirmed either: new AWS services take time to join the assessed list. Check with the client

Sources, checked on 30 October 2026: Cloudflare Containers pricing, limits, placement and jurisdictions, the Containers API, Workers VPC, the closed Terraform pull request, Pulumi dynamic providers, Lambda MicroVMs, MicroVMs in Sydney, Lambda pricing.

More choices

  1. 01 Lambda, Web Functions or Workers? Where should this piece of logic run?
  2. 02 Lambda, Fargate or EC2? My Lambda is busy all day, or its reserved concurrency keeps going up. When is it time to move to a container, and where is the line?
  3. 03 Longer than 15 minutes: Fargate, durable functions or Managed Instances? My job runs past Lambda's 15 minutes, maybe for hours, and I don't know when it ends. Where does it run, and how does it stop billing once done?
  4. 04 Runpod or AWS for a GPU? I need an NVIDIA GPU for models and experiments. Do I rent it on Runpod, or on AWS with SageMaker or EC2, and when do I use both?
  5. 06 SQS, EventBridge or SNS? Something happens in my app and other code must act on it. Do I put it in a queue, on an event bus, or on a topic?
  6. 07 Queue, bus or stream? SQS, EventBridge, Kinesis or Kafka Events move between my services. Are SQS, SNS and EventBridge enough, or do I need a stream like Kinesis or Kafka, and at what scale does the answer change?
  7. 08 Kinesis or Kafka on AWS? I need a real stream on AWS. Kinesis Data Streams, or Kafka on Amazon MSK, and is running Kafka myself ever worth it?
  8. 09 SQS retries or Durable Functions? A job calls something flaky (a third-party API, an LLM, a slow Postgres). How do I retry it reliably, and when do I reach for Lambda durable functions instead of tuning SQS?
  9. 10 Durable functions or Step Functions? A job has several steps, retries and waits. Do I write it as a Lambda durable function, or as a Step Functions state machine?
  10. 11 pgvector or S3 Vectors? Where should my embeddings live?
  11. 12 Pulumi or Terraform? We're putting our infrastructure in code. Pulumi or Terraform, and what if we already run one of them?
  12. 13 Cloudflare or S3 and CloudFront for a website? Where should a website, SPA or PWA live, Cloudflare static hosting or S3 behind CloudFront, and where do its heavy files go?
  13. 14 CloudWatch and Firehose, side by side How do I keep chatty logs without a CloudWatch-sized bill?
  14. 15 Athena or DuckDB? How should I query my data lake, and what changed when AWS bought DuckDB's company?
  15. 16 Neon or Aurora? I need Postgres for an app on AWS. When is Neon the right call, and when does it have to be Aurora?
  16. 17 Better Auth or Cognito? Which sign-in should my app use, and what do I actually get for free?
  17. 18 Why I ended up on AWS Which cloud should my company run on, and is AWS just the one you know?
  18. 19 Better Auth, run yourself or managed by Neon? My app is on Neon. Should I run Better Auth myself, or switch on Neon Auth, which is Better Auth managed by Neon?
  19. 20 Stripe or PayPal Should we take payments with Stripe or PayPal, and when is PayPal worth the pain?
  20. 21 Tailscale or Cloudflare Tunnel? I need to reach a private box or VPC, or put a service from it online. Is that Tailscale or Cloudflare Tunnel?
  21. 22 Resend or SES? Our app sends email, and maybe a newsletter. Resend, or Amazon SES in our own AWS account?
  22. 23 WhatsApp or Telegram Our bot should reach users in a messaging app. WhatsApp or Telegram, and why did yours get blocked?
  23. 24 Which model, at what price Claude, GPT or an open model? Which is the cheapest model that's good enough, tier by tier?
  24. 25 Anthropic API, Bedrock or OpenRouter? My product will call Claude. Do I buy it from Anthropic directly, through Amazon Bedrock in the client's AWS account, or through OpenRouter?
  25. 26 Which decision model? Jev, OpenAI Decisions, Clef, Baseten, Perplexity or Liquid? Which decision model fits my job, my volume and my risk?
  26. 27 Cloudflare AI Gateway, OpenRouter or LiteLLM? My app calls several LLMs. Do I need an AI gateway, and which one: Cloudflare AI Gateway, OpenRouter, or a LiteLLM proxy I host myself?
  27. 28 Function URL or API Gateway? My Lambda needs an HTTPS endpoint. When is a function URL enough, and when do I start on API Gateway from day one?
  28. 29 Serper or DataForSEO Should an agent get Google results from Serper or from DataForSEO, and do the two overlap or work together?

Want this stack in your AWS account?

Cloudless Labs is a Sydney consultancy. We migrate on-premises systems to AWS, build serverless apps on this stack, and coach teams to ship with Claude Code and Codex.

Talk to us

Contact Us

For general inquiries, please contact us at:

For e-learning capabilities, please contact: