Skip to Content
Kandang

Sandbox and limits

What every run gets, and where it stops.

Every run gets its own gVisor sandbox: a user-space kernel that sits in front of the host's, so the code never talks to the host kernel directly.

What a run can't do

TryWhat happens
Open a socketNetwork unreachable. The run has its own network namespace and runsc --network=none.
Allocate more than 1 GiBKilled with exit code 137.
Run past its timeoutThe whole cgroup is killed, exit code 124.
Fork without endStops at 64 processes with a clean EAGAIN.
Write to the rootThe root filesystem is read-only.
Gain privilegesIt runs as uid and gid 10001 with no capabilities and noNewPrivileges.

Limits

WhatLimit
Code100 KB
Input files20 files, 15 MiB each, 50 MB in total
Request bodyAbout 68 MiB, checked before decoding
Output files10 files from /work/out, 15 MiB each
stdout, stderr32 KB each, head and tail
Timeout60 s by default, 300 s at most
Memory1 GiB, no swap
CPUOne CPU
Processes inside64
Host pids256, gVisor's own threads included
Open files1024
/tmp256 MB tmpfs inside the sandbox
/work512 MB tmpfs per run
Concurrency2 runs at once and 10 waiting, then 429 busy

Measured

On a Mac mini M4 (arm64):

JobTimePeak memory
Start a sandbox25 to 36 ms
Light Python jobAbout 0.6 sAbout 50 MB
pandas chart over 500,000 rowsAbout 3.5 sUp to 225 MB
12 MP photo editAbout 0.4 s145 MB

A run, step by step

  1. The request is checked, then waits for one of the two run slots.
  2. Kandang mounts a 512 MB tmpfs for the run and writes the script, in/ and an empty out/ into it, owned by uid 10001.
  3. It writes the OCI config: the shared rootfs read-only, tmpfs /tmp, the run's dir at /work, its own pid, network, ipc, uts and mount namespaces, and hostname kandang.
  4. It creates a cgroup with the limits above and starts runsc straight into it, so the sandbox is capped from its first instruction.
  5. On timeout it kills the whole cgroup.
  6. It reads the peak memory and /work/out, then removes the sandbox, the cgroup, the tmpfs and the run dir. Whatever a crash leaves behind is swept at the next start.

On this page