8. Shared sandbox
8. Shared sandbox¶
Result: works. The Spanner emulator and a job, as two containers in one CRI pod under gVisor, reach each other on localhost. The emulator is usable about 1.5 s after the pod starts, and the whole pod uses about 36 MiB more than nothing, measured on its job cgroup.
Setup (2026-11-22)¶
- As experiment 7: containerd 1.7.24 CRI, gVisor
runschandler, a job cgroup under/sys/fs/cgroup/allmyram(2 GiB limit, no swap) as the pod'scgroup_parent. spike/cri_shared_sandbox.py: start a pod, start the emulator (gcr.io/cloud-spanner-emulator/emulator:latest) in it, then a probe container (python:3.13-alpine) that pollshttp://127.0.0.1:9020/v1/projects/…/instancesuntil 200, creates an instance and reads it back (experiment 5's readiness test, from inside the pod). Three runs each underrunscandrunc; images pulled beforehand.
Raw results¶
| Runtime | Probe exit | Probe: live / usable (s) | Pod start → probe exit (s) | Job cgroup now / peak (MiB) |
|---|---|---|---|---|
| runsc | 0 | 0.26 / 0.27 | 2.52 | 38.9 / 57.0 |
| runc | 0 | 0.58 / 0.58 | 1.47 | 16.6 / 30.6 |
| runsc | 0 | 0.25 / 0.25 | 1.35 | 35.9 / 54.5 |
| runc | 0 | 0.63 / 0.63 | 1.38 | 16.4 / 31.1 |
| runsc | 0 | 0.31 / 0.31 | 1.55 | 35.9 / 54.1 |
| runc | 0 | 0.58 / 0.58 | 1.38 | 16.6 / 30.8 |
The emulator was still running when the probe exited in every run.
What we learned¶
- One sandbox per job works. A CRI pod is one gVisor sandbox. Its
containers share a network namespace, so a job reaches its services on
127.0.0.1with no per-job network, no name lookup and no published ports. This replaces experiment 6's per-job Podman network. - Start-up cost is small. From pod start to a usable emulator and a
finished probe is 1.35–1.55 s warm under gVisor, against about 1.4 s under
runc. The first run (2.52 s) included one-time work. The probe sees the emulator live sooner under gVisor (0.25 s versus 0.6 s); I haven't looked into why, and it doesn't change the total much. - gVisor's memory cost is about 20 MiB per pod, not 410. Measured on the
job cgroup, the emulator plus probe pod holds 36–39 MiB under gVisor
against 16–17 MiB under
runc(peaks 54–57 versus 31). Experiment 5's ~410 MiB summedVmRSSacross processes, which counts shared memory repeatedly; the cgroup is the number to use. The emulator was idle with one instance, so a busy test run will use more, under either runtime.
What it changes¶
- A job and its services are one CRI pod in one job cgroup: one sandbox, one limit, one localhost. Services start first; the job waits for its services' readiness checks, which run inside the pod.
- Memory per sandbox no longer limits how many jobs a runner can hold; the jobs' own memory does.