Runtime

Cloudflare Sandbox vs CodeSandbox SDK: pricing, isolation and limits

Cloudflare bills active CPU in 10 ms steps; CodeSandbox bills a fixed VM size by the minute, rounded up, busy or not.

Runtime charges 53% less than Cloudflare and 74% less than CodeSandbox for the same agent job. A thousand one-minute runs at 2 vCPU come to $1.35 on Cloudflare, $2.48 on CodeSandbox and $0.64 on Runtime. Runtime counts measured CPU second by second, never rounds a run up to a whole minute, and takes any mix of vCPUs and memory you ask for. Rates checked 23 September 2026.

Estimated compute cost

53% less than Cloudflare Sandbox74% less than CodeSandbox

2 vCPUs · 4 GiB · 60 s a run · 20 CPU-seconds busy

1,000

Compute only, at list rates checked 23 September 2026 (Cloudflare Containers pricing, Together Code Sandbox). Plan fees, network, taxes and free credits are left out. The worked example below shows the arithmetic.

At a glance

The Sandbox SDK is billed as Cloudflare Containers, whose rates appear here. CodeSandbox's rates are from Together's documentation of the CodeSandbox SDK; CodeSandbox is a Together company.

Cloudflare Sandbox SDK CodeSandbox SDK Runtime
Isolation A container in its own VM Firecracker microVM Firecracker microVM, own kernel
CPU $0.072 per active vCPU-hour By VM size: Nano (2 cores, 4 GB) is $0.1486 an hour $0.025 per vCPU-hour of measured CPU, with a small floor
Memory $0.009 per provisioned GiB-hour; at least 3 GiB per vCPU Inside the VM size $0.0075 per reserved GiB-hour
Billing step 10 ms of CPU A minute, rounded up By the second
Largest 4 vCPUs, 12 GiB and 20 GB of disk 64 cores and 128 GB vCPUs and memory chosen per sandbox
At once 1,500 vCPUs and 6 TiB of memory per account 10 VMs on Build; 250 on Scale 100 sandboxes to start on a paid account
Plan fee Workers Paid, at least $5 a month Build free; Scale $170 a month None; prepaid credit from $10
Snapshots, forks A directory backed up to R2 Memory snapshot and restore Files, memory and running processes

Which is cheaper for short runs?

Cloudflare, by a wide margin, and the shorter the run the wider it gets. CodeSandbox bills a Nano VM at 10 credits an hour, $0.1486, and rounds each VM's time up to the next minute, so a 40-second run is billed as 60. Cloudflare meters CPU in 10 ms steps and prices memory and disk per second.

Shorten the example below to 40-second runs with the same 20 CPU-seconds of work, and 1,000 of them cost $1.03 on Cloudflare, still $2.48 on CodeSandbox, and $0.47 on Runtime. The order only changes for busy work: with a fixed price per minute, CodeSandbox becomes the cheaper rival once a one-minute run uses more than about 76 of its 120 CPU-seconds.

Cost for the same job

For the full one-minute case: 1,000 runs on 2 vCPU, 60 seconds each, 20 CPU-seconds of computing per run. CodeSandbox runs a Nano VM, which has 4 GB, and Runtime gets 4 GiB. Cloudflare's floor of 3 GiB per vCPU makes its smallest 2 vCPU shape 6 GiB, and the disk is 12 GB as in Cloudflare's example.

TextCloudflare   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.35CodeSandbox  Size   1,000 × 60 s / 3,600 × $0.1486     = $2.48Runtime      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

At 100,000 runs a month: $135.04 on Cloudflare, $247.67 on CodeSandbox and $63.89 on Runtime. Keep both CPUs busy for the whole minute and it is $1.33 on Runtime, $3.35 on Cloudflare and $2.48 on CodeSandbox. The Nano's price does not move at all. Cloudflare's figure assumes each sandbox is destroyed after its run; plan fees, Workers requests, Durable Object time, storage, network and free allowances are excluded.

Is a microVM safer than Cloudflare's container?

Both put a virtual machine boundary around your code. Cloudflare runs each sandbox as a container inside its own VM. CodeSandbox and Runtime run each sandbox as a Firecracker microVM with its own Linux kernel. MicroVM vs container explains the difference, and Firecracker what the microVM is.

On Runtime, root inside the sandbox cannot change its network, CPU, memory or cost, and a sandbox can run with its internet off or with an allow list. See how to turn off sandbox internet.

Which one to pick

  • Short, bursty runs inside a Workers app: Cloudflare Sandbox, which also places sandboxes near users on its network.
  • Big machines or a large busy fleet: the CodeSandbox SDK, with VMs up to 64 cores and 128 GB, memory snapshots, and up to 250 VMs on the Scale plan.
  • Per-second billing for an agent that waits: Runtime, whose measured CPU costs about a third of Cloudflare's rate, with any shape of vCPUs and memory and forks that copy a running sandbox, memory included.

Moving the code

Cloudflare's calls have direct equivalents, getSandbox(env.Sandbox, name) as Sandbox.getOrCreate(name), sandbox.exec(cmd) as exec and proxyToSandbox as box.previews.create(port), and once ported the code no longer has to live in a Worker. With CodeSandbox, start a Runtime sandbox where you started a VM, send commands through exec, and call stop() where the VM was shut down.

TypeScriptimport { Sandbox } from "withruntime";const box = await Sandbox.create({ funding: "trial" });try {  console.log((await box.exec("python3 -c 'print(6 * 7)'", { check: true })).stdout);} finally {  await box.stop();}

A coding agent given the instruction in migration will do the port on a branch and test it on the free trial. Cloudflare users who run npx withruntime switch --from cloudflare before the first top-up get it matched in credit, up to $100. Full comparisons: Runtime vs Cloudflare, Runtime vs CodeSandbox.

Sources

Rates checked 23 September 2026; Cloudflare's sandbox lifecycle page read 25 September 2026.

Facts on this page were checked on 25 September 2026.