Skip to content

Sandbox Cost Model: Wall-Clock vs Active-CPU Billing

Aug 30, 20261 min
TL;DRThe cost post (order 26) of the Sandbox Series. Compares wall-clock vs active-CPU billing models, cost differences across isolation layers, and how to estimate monthly cost and avoid hidden fees.

Look up & save

Loading dictionary…

🌏 中文版

What This Post Is

This post is the "cost" post (order 26) of the Sandbox Series. It doesn't compare single provider features (provider deep dives are in order 8–16, landscape in order 7). It focuses on "how sandboxes charge":

  1. What's the difference between wall-clock and active-CPU billing?
  2. What's the cost difference across isolation layers? (container, gVisor, microVM, Wasm)
  3. How to estimate monthly cost? — With calculation formulas and examples.
  4. What are the hidden fees? — Network egress, snapshots, idle fees, etc.
  5. How to optimize sandbox costs?

Two Billing Models: Core Differences

Wall-Clock Billing

Charges for every second the sandbox is alive, regardless of whether CPU is busy. As long as the sandbox isn't destroyed, it keeps billing.

Suitable for: Long-running continuous tasks, sessions that need state retention. Providers: E2B, Daytona, Runloop, Modal (no idle charge exception), AWS Bedrock AgentCore, Azure Container Apps.

Active-CPU Billing

Charges only for actual CPU time executing code. I/O wait and idle time are not billed.

Suitable for: Bursty, short-execution, long-wait interactive agents. Providers: Vercel Sandbox, Cloudflare Sandboxes.


Cost Scenario Simulation

Scenario A: Bursty Interactive Agent

30,000 sessions/month, 5 minutes each, actual CPU usage only 30 seconds, 2 vCPU + 4 GB memory.

Billing ModelEstimated Monthly CostNotes
active-CPU (Vercel/Cloudflare)~$36–$276Only actual CPU time, skips wait
wall-clock (E2B/Daytona)~$414Every second counts, idle also billed

Conclusion: Bursty scenarios can save 90%+ cost with active-CPU.

Scenario B: Long-Running Continuous Execution

1,000 sessions/month, 8 hours each, 60% CPU utilization, 4 vCPU + 8 GB memory.

Billing ModelEstimated Monthly CostNotes
wall-clock (E2B/Daytona)~$1,200Fixed cost, predictable
active-CPU (Vercel)~$1,500+Although only active CPU, long-running accumulates higher

Conclusion: Long-running scenarios: wall-clock is more predictable and usually cheaper.


Cost Comparison Across Isolation Layers

Isolation LayerRepresentative TechRelative CostStartup SpeedMemory OverheadSuitable Scenario
ContainerDocker$ (lowest)1–5 s50–100 MBTrusted code, CI tasks
User-space kernelgVisor$$100–300 ms10–30 MB extraMulti-tenant, Kubernetes
Lightweight VMFirecracker/Kata$$$125 ms5–128 MBUntrusted code, multi-tenant
WebAssemblyWasmtime/WasmEdge$ (lowest)3–15 ms< 1 MBShort-lived code fragments, edge
Managed sandboxE2B/Modal/Vercel$$$$0.3–5 sDepends on providerFast delivery, low ops

Key insight: Wasm sandbox has the lowest memory overhead (<1 MB) and fastest startup (3–15 ms), suitable for high-concurrency short-lived execution; but it can only run Wasm-compiled languages, limited language ecosystem.


Hidden Fee Checklist

Many teams only look at the sticker price, ignoring these hidden costs:

1. Network Egress

Network traffic sent out from the sandbox is usually billed by traffic volume. If agents frequently call external APIs or download large files, network fees may exceed compute costs.

Recommendation: Set network allowlists inside the sandbox to restrict unnecessary outbound traffic.

2. Snapshots & Storage

Sandbox snapshots, temporary files, persistent disks are usually billed by storage size. Long-retained snapshots accumulate costs.

Recommendation: Set snapshot retention policy (e.g., keep only latest 3), regularly clean up unused storage.

3. Idle Fees

Some providers charge lower but non-zero fees for idle sandboxes, or set minimum billing units (e.g., minimum 1 minute billing).

Recommendation: Use auto-destroy for short tasks, use pause/resume instead of continuous running for long tasks.

4. GPU Fees

If the sandbox needs GPU (e.g., ML inference), GPU fees are usually much higher than CPU fees.

Recommendation: Only attach GPU when needed, release immediately after use.


Monthly Cost Estimation Formula

Monthly Cost = (CPU hours × CPU rate) + (Memory GB-hours × Memory rate) + (Network GB × Network rate) + (Storage GB × Storage rate) + (GPU hours × GPU rate) + Fixed base fee

Example Calculation

Assumptions:

  • 10,000 sessions/month, 10 minutes each
  • 2 vCPU, 4 GB memory
  • CPU utilization 30%
  • Network egress 100 GB/month
  • Wall-clock billing, CPU rate $0.000014 / vCPU-s, memory $0.0000045 / GiB-s
CPU hours = 10,000 × 10 minutes × 60 seconds × 30% = 180,000 seconds
CPU cost = 180,000 × 2 vCPU × $0.000014 = $5.04
Memory cost = 180,000 × 4 GB × $0.0000045 = $3.24
Network cost = 100 GB × $0.09 = $9.00
Total ≈ $17.28/month

Cost Optimization Strategies

StrategyDescriptionApplicable Scenario
Choose right billing modelBursty → active-CPU, Long-running → wall-clockAll scenarios
Set auto-destroyDestroy sandbox after task completes, avoid idle billingShort-lived tasks
Use pause/resumePause instead of destroy for long tasks needing state, resume to continueWorkflows needing state retention
Limit network egressSet allowlist, avoid unnecessary external trafficAgents frequently calling external APIs
Set snapshot retentionKeep only latest N snapshots, regularly clean upProviders using snapshots
Choose Wasm sandboxLowest memory & startup cost, suitable for short-lived codeWasm-compatible languages
Monitor & alertSet cost alerts to avoid bill surprisesProduction environments

What You Should Understand After Reading

  1. Difference between wall-clock and active-CPU billing models, and applicable scenarios.
  2. Relative cost across isolation layers (container, gVisor, microVM, Wasm, managed sandbox).
  3. How to estimate monthly cost using the formula, and what hidden fees exist.
  4. How to choose the most economical sandbox solution based on workload characteristics.
  5. Five cost optimization strategies you can implement immediately.

References