Guide 09 · multi-tenant isolation
Run untrusted user code in your product
Plugin systems, coding-education platforms, user-defined webhooks — anywhere strangers' code runs, it must not run on your infrastructure. Give each execution a microVM with hard caps and a deadline.
1
Cap everything at create time
sb = Sandbox.create( template="python-3.11", vcpu=1, memory_mb=512, storage_mb=1024, # hard resource walls timeout=30, # hard deadline — reaped after 30 s )
2
Execute with a per-command timeout too
r = sb.run(user_code_command, timeout=10) verdict = {"stdout": r.stdout, "exit": r.exit_code} sb.kill() # nothing survives the request
3
Why this is safe
Each sandbox is a dedicated microVM — its own kernel, not a shared-kernel container. Escapes that work on containers hit a hardware virtualization boundary here. Server-side plan limits cap concurrency and resources even if your own service has a bug.
a 30 s · 1 vCPU · 0.5 GB run ≈ $0.0005 ·
isolation comparison