Skip to main content
There are two ways to start from a prepared sandbox: Both begin each task exactly where the prepared sandbox was, with its files and memory, in about the time of a create.
1

Prepare one sandbox and save it

Install your dependencies and check out your repository in the first command; every task then starts with them in place. The snapshot outlives the sandbox it was taken from, so kill the prepared sandbox now: it would otherwise count against your concurrency limit while the tasks run.
2

Start the tasks in parallel

The Python version runs three tasks with at most two sandboxes alive at a time (inside the trial’s limit of 3 VMs at once; raise MAX_PARALLEL on a plan that allows more). Each task creates a sandbox from the snapshot, runs one command, collects the result, and kills the sandbox even when it fails. A 429 or 503 is retried after Retry-After.Starting many sandboxes at once from Node: each sandbox is reached at a host name of its own (49983-<id>.<domain>), and Node resolves each new name on libuv’s four DNS threads, so the first command of a hundred sandboxes started together waits in a queue of lookups. Measured on 2026-11-17 with the E2B JavaScript SDK, 100 sandboxes created at once from a server in the same region: the median first command took 750 ms; with UV_THREADPOOL_SIZE=128 in the process environment it took 255 ms.
The Python version prints:
The TypeScript version prints the same lines for its two tasks. Promise.all starts every task at once, so keep the list within your concurrency (two tasks here, inside every plan’s limit); for more tasks than that, take them from a queue with a fixed number of workers instead of mapping over the whole list.

Fork instead: copies of a running sandbox

Use a fork when the tasks need the live state of one sandbox (a warmed interpreter, a loaded model, a running server).
The answer lists the children, each with its own sandboxID; kill them when the tasks end. The parent counts too, so on the trial (three VMs at once) fork with at most "count": 2.

Concurrency limits

Size your parallelism to the limit of your account, read in GET /v1/run/usage (concurrent_sandboxes, caps), and keep the retry on 429 capacity_provisioning and 503 capacity as the examples do. The API applies no per-key request rate limit. See limits and errors.

Keep it clean

  • A refused create holds nothing, so retrying it is safe. Kill what you create in a finally: a sandbox you forget runs and bills until its timeout.
  • Give each task its own timeout shorter than the job; the sandbox ends by itself if your harness dies.
  • Tag sandboxes with metadata (a run id) and list them with GET /sandboxes to clean up after a crash.
  • To tell a failed task from a failed platform in a harness, branch on the error’s origin: see errors.