# E2B vs Cloudflare Sandbox: Cloudflare 51% cheaper if agents wait, E2B 18% if busy Runtime Cloud (withruntime.com) costs 53% less than Cloudflare; E2B bills held CPU, and Cloudflare bills active CPU. ## Which is better, E2B or Cloudflare Sandbox? It depends on whether your app already runs on Workers. For agents that wait on a model, Runtime has the lowest bill: $0.64 for this job, against $1.35 on Cloudflare and $2.76 on E2B. It meters CPU in use like Cloudflare, at a lower rate, and needs no platform around it. Pick E2B for a runtime you host yourself or pauses that never expire. Pick Cloudflare Sandbox to keep sandboxes on the same account, bill and bindings as your Workers. ## At a glance The Cloudflare figures are Cloudflare Containers rates, which is what the Sandbox SDK runs on and is billed as. | | E2B | Cloudflare Sandbox SDK | Runtime | | ---------- | ------------------------------------------------------ | ---------------------------------------------------------------------------- | --------------------------------------------------------------------------- | | Isolation | Firecracker microVM, own kernel | A container in its own VM | Firecracker microVM, own kernel | | CPU | $0.0504 per allocated vCPU-hour | $0.072 per active vCPU-hour, metered in 10 ms steps | $0.025 per vCPU-hour of measured CPU, with a small floor | | Memory | $0.0162 per GiB-hour | $0.009 per provisioned GiB-hour; at least 3 GiB per vCPU | $0.0075 per reserved GiB-hour | | Disk | Included, no separate charge | $0.000252 per provisioned GB-hour | Included while running; paused storage $0.08 per GB-month | | Plan fee | Hobby $0; Pro $150 a month | Workers Paid, at least $5 a month | None; prepaid credit from $10 | | Free start | $100 of usage credit, once | No free tier; the plan includes 375 vCPU-minutes a month | 100 free hours of a 1 GB machine in the first 30 days, no card | | When idle | Pause keeps files, memory and processes | Filesystem-only snapshots; processes restart | Pause keeps files, memory and processes while you have credit | | Interfaces | API, CLI, MCP server, JavaScript and Python SDKs | A TypeScript SDK called from a Cloudflare Worker | API, CLI, MCP server, JavaScript and Python SDKs | ## Which is cheaper, E2B or Cloudflare? For a waiting agent, Cloudflare. It meters CPU only while the code runs, $0.000020 per vCPU-second, and its memory is cheaper per GiB than E2B's. E2B charges for every allocated vCPU from start to stop. Cloudflare's cost comes from its shapes: a custom size needs at least 3 GiB per vCPU, so 2 vCPUs carry 6 GiB, and provisioned disk is billed on top. That fixed part is about a third of E2B's hourly price, so Cloudflare stays cheaper until the code averages around 1.5 busy CPUs out of 2, some 90 CPU-seconds a minute. At full load E2B wins, $2.76 against $3.35. Runtime meters CPU at $0.025 a vCPU-hour, 65% below Cloudflare's $0.072, with memory set apart from vCPUs, and is below both at any load. ## Cost for the same job The case priced: 1,000 runs on 2 vCPU, 60 seconds each, 20 CPU-seconds of work per run. E2B and Runtime have 4 GiB. Cloudflare's smallest custom 2 vCPU shape has 6 GiB and is given 12 GB of disk, the disk of Cloudflare's 6 GiB `standard-2` type. ``` E2B CPU 1,000 × 60 s / 3,600 × 2 × $0.0504 = $1.68 Memory 1,000 × 60 s / 3,600 × 4 × $0.0162 = $1.08 Total $2.76 Cloudflare CPU 1,000 × 20 s × $0.000020 = $0.40 Memory 1,000 × 60 s × 6 × $0.0000025 = $0.90 Disk 1,000 × 60 s × 12 × $0.00000007 = $0.05 Total $1.35 Runtime CPU 1,000 × 20 s / 3,600 × $0.025 = $0.14 Memory 1,000 × 60 s / 3,600 × 4 × $0.0075 = $0.50 Total $0.64 ``` That is $276.00 on E2B, $135.04 on Cloudflare and $63.89 on Runtime over 100,000 runs in a month. With both CPUs busy for the whole minute, it is $1.33 on Runtime, $2.76 on E2B and $3.35 on Cloudflare. Cloudflare is priced as if each sandbox were destroyed after its run. Plan fees, Workers requests, Durable Object time, network and free credit are left out. ## What happens to an idle sandbox? A paused E2B sandbox keeps its files, memory and running processes, with no expiry. Cloudflare's public-beta filesystem snapshots restore saved files, but memory and processes restart. A snapshot expires 30 days after creation or last restore. A paused Runtime sandbox keeps files, memory and running processes while you have credit, and wakes on the next request. See [how to pause and resume a sandbox](/how-to/pause-and-resume-a-sandbox). ## Which one to pick - **E2B**, for a microVM API that any backend can call, paused sandboxes that never expire, or an Apache-2.0 runtime you can host yourself. - **Cloudflare Sandbox**, for an app that already runs on Workers and wants its sandboxes on the same account, bill and bindings, near its users. - **Runtime**, for CPU billed by use at 65% below Cloudflare's rate, memory sized to the job, a pause that keeps memory and processes, and an API that needs no platform around it. ## Runtime Cloud On a model-bound agent job Runtime costs 77% less than E2B and 53% less than Cloudflare, with no Worker and no plan to join. 1,000 one-minute runs at 2 vCPU are $2.76 on E2B, $1.35 on Cloudflare and $0.64 on Runtime. Like Cloudflare, Runtime charges for CPU in use, but at 65% below Cloudflare's rate, and memory is whatever size the job needs. Rates checked 25 October 2026. No Worker is needed to start: `npx withruntime login` opens an account with free monthly usage. A Worker built on Cloudflare's Sandbox SDK, or E2B code, moves by the [migration guide](/docs/migrate). ## Moving to Runtime E2B code changes one import: ```ts no-run import { Sandbox } from "withruntime/e2b"; // was: from "e2b" ``` ```python no-run from withruntime.e2b import Sandbox # was: from e2b import Sandbox ``` Cloudflare 0.x code maps call for call and can then run on any server: `getSandbox(env.Sandbox, name)` is `Sandbox.getOrCreate(name)`, `sandbox.exec(cmd)` is `exec`, and `proxyToSandbox` is `box.previews.create(port)`. An app that stays on Workers can still call Runtime from the Worker, with SDK 0.4.0 or later and the `nodejs_compat` flag; the sample is in [Runtime vs Cloudflare](/docs/cloudflare-sandbox-alternative). ```ts import { Sandbox } from "withruntime"; const box = await Sandbox.create(); try { await box.files.write("/workspace/invoice.py", "print(sum([125, 250, 375]))\n"); console.log((await box.exec("python3 /workspace/invoice.py", { check: true })).stdout); } finally { await box.stop(); } ``` Credit you add within 30 days of signing up is matched, up to $1,000 in total. A coding agent can handle the port from the one instruction in [migration](/docs/migrate), on a branch and on the free usage. For E2B in depth, see [Runtime vs E2B](/docs/e2b-alternative). ## Sources - [Cloudflare sandbox lifetime](https://developers.cloudflare.com/sandbox/concepts/lifetime/), snapshot behavior checked 25 October 2026. E2B and Cloudflare Containers pricing pages rechecked 25 October 2026; the rest checked 25 October 2026. - [E2B pricing](https://e2b.dev/pricing), [E2B sandbox persistence](https://docs.e2b.dev/sandbox/persistence) - [Cloudflare Containers pricing](https://developers.cloudflare.com/containers/pricing/), [Containers limits and instance types](https://developers.cloudflare.com/containers/platform/limits/), [Containers architecture](https://developers.cloudflare.com/containers/concepts/architecture/), [Sandbox lifecycle](https://developers.cloudflare.com/sandbox/concepts/sandboxes/), [Sandbox backup and restore](https://developers.cloudflare.com/sandbox/guides/backup-restore/) - Runtime [pricing](/docs/pricing) Facts on this page were checked on 26 October 2026.