Skip to content

Interview question · Agent Runtime & Sandboxes

Design tenant isolation for twenty thousand concurrent coding sessions.

The sandbox boundary is one layer of six. Compute, network, storage, credentials, shared caches and observability each need their own answer, and the shared caches are where designs usually leak.

expertNewUpdated Nov 2026

TL;DR: Isolate at every layer a tenant's data or code touches. Compute: a microVM (or gVisor sandbox) per session, never reused, with dedicated host pools for tenants who require them. Network: per-session egress through brokers, no traffic between sandboxes. Storage: per-session workspaces, per-tenant encryption keys, persisted workspaces keyed by tenant. Credentials: minted per session by a broker. Shared caches (packages, build artefacts, images, model responses): keyed by tenant or limited to public content. Observability: tenant-tagged, access-controlled. Then size the fleet, enforce quotas against noisy neighbours, and prove isolation with cross-tenant canary tests.

How to approach it

List every layer a session touches, give the isolation mechanism for each, then do the capacity arithmetic and finish with how you would prove it holds.

A strong answer

The layers.

LayerMechanismThe usual leak
ComputeMicroVM per session, destroyed after; dedicated hosts for regulated tenantsReusing sandboxes for speed
NetworkEgress only to brokers and mirrors; no sandbox-to-sandbox traffic; metadata blockedA flat network between sandboxes
StorageSession scratch disks; persisted workspaces per tenant, encrypted with per-tenant keysShared volumes or snapshots containing tenant code
CredentialsBroker mints short-lived per-session tokensLong-lived tokens in images
Shared cachesPackage mirror for public packages only; build caches keyed by tenant; snapshots per tenant repositoryA shared build cache that one tenant can poison or read
Model calls and logsRequests and caches keyed by tenant; logs tagged and access-controlledA response cache keyed by prompt only

Shared caches deserve the attention. Caching is how the platform stays fast at this scale, and it is the easiest way to move one tenant's bytes into another's session: a build cache entry produced from tenant A's code and reused by tenant B, a snapshot of a private repository used as a base for others, a response cache keyed without the tenant. Rule: content derived from a tenant's code or data is cached only under that tenant's key; only public content (open-source packages from a verified mirror) is shared.

Capacity.

from math import ceil

def fleet(sessions, vcpu, mem_gb, host_vcpu=96, host_mem_gb=768,
          overcommit_cpu=2.0, headroom=0.2):
    per_host_cpu = host_vcpu * overcommit_cpu // vcpu
    per_host_mem = host_mem_gb // mem_gb              # memory is not overcommitted
    per_host = int(min(per_host_cpu, per_host_mem) * (1 - headroom))
    return per_host, ceil(sessions / per_host)

print(fleet(20_000, vcpu=2, mem_gb=8))  # => (76, 264)

With 2 vCPUs and 8 GB per session, a host fits 96 sessions by memory and, with CPU overcommitted twofold, 96 by CPU; 76 after headroom, so about 264 hosts. Without the overcommit, CPU would cap it at 48 and the fleet would double. Coding sessions are mostly idle between bursts, which is why CPU can be overcommitted while memory usually is not.

Noisy neighbours. Per-session limits on CPU, memory, disk I/O and network; per-tenant quotas on concurrent sessions; scheduling that spreads a tenant's sessions so one tenant's burst does not starve a host.

Prove it. Canary tests across every path: a marker written in tenant A's workspace, build cache, snapshot and logs, then searched for from a session of tenant B through each read path, in CI and periodically in production. Hostile-snippet tests for each sandbox image. Regular review of cache keying when new caches are added.

What interviewers probe next

"Per-session microVMs are expensive at this scale." Snapshots and warm pools keep start-up cheap; density comes from memory sizing and idle-time overcommit of CPU. The cost of a cross-tenant incident is far higher.

"Enterprise customers ask for dedicated infrastructure." Dedicated host pools per tenant with the same images and controls; the isolation model does not change, only the sharing of hardware.

"Where do model provider calls fit?" Requests carry tenant identifiers for internal accounting; provider-side caching is per account, and any internal caching follows the tenant-keyed rule.

How it's scored

Weak: Containers per session on a shared cluster.

Hire: MicroVM or gVisor per session, egress control, per-session credentials and per-tenant storage.

Strong Hire: Covers compute, network, storage, credentials, shared caches and observability with the typical leak for each, keys every derived cache by tenant, sizes the fleet with memory-bound density and CPU overcommit, controls noisy neighbours, offers dedicated pools, and proves isolation with cross-tenant canaries and hostile-snippet tests.

Common mistakes

  • Isolating compute and forgetting caches and snapshots.
  • Reusing sandboxes between sessions for start-up speed.
  • A flat network where sandboxes can reach each other.
  • No tests that actually try to cross tenants.
You just read a free answer. Every topic opens its first 5 answers to anyone. Sign in and the count per topic goes to 6, and the site remembers where you stopped in each one.Google sign-in · free · no payment details
HOW DID IT GO?
0
READING SIGNED OUT

Signing in raises your free answers from 5 to 6 per topic, adds an applied lesson in every topic and easy practice tests, and the site starts remembering you: mastery per topic, bookmarks, and a next-focus recommendation. Free, no card.

Sign in free
UP NEXT ON YOUR JOURNEY
DISCUSSION · 0

Nobody has commented. Post a correction or another way to answer.