KatInterview

Designing an isolated notebook execution platform

System DesignModel answer
MediumModel answerSystem Designsystem-designsandboxingmulti-tenancy

Last updated

Design a multi-tenant cloud notebook platform that runs untrusted user code in isolated sandboxes and streams output, with focus on isolation, lifecycle, persistence and observability.

Design a sandboxed cloud notebook platform

You are designing a browser-based, multi-tenant notebook/IDE service where users write code, execute it in a remote isolated environment, and watch the results appear live.

What users do

  • Open a workspace (project or notebook), edit code in the editor, and run individual cells or shell commands.
  • See results in the UI: stdout, stderr, rich outputs (plots, HTML, images).
  • Watch log output streaming while the code is still running.

Requirements

Functional

  • Spin up an isolated compute environment for each workspace/session.
  • Execute arbitrary user-supplied code without harming the platform or other tenants.
  • Stream execution output and logs to the browser with low latency.
  • Support file upload/download and persistent workspace state between sessions.
  • Collaboration is optional — if you include it, say so explicitly and keep it simple.

Non-functional

  • Tenant isolation is the top priority; security failures are unacceptable.
  • New sessions should start quickly enough to feel interactive.
  • The platform must autoscale and share resources fairly across tenants.
  • Observability: metrics, tracing, and audit logging.

What to cover

  • How you pick and manage the compute substrate (plain VMs vs. containers vs. microVMs).
  • The isolation model: filesystem, network, process, credentials.
  • The architecture for streaming output/logs.
  • Lifecycle management: create, run, go idle, suspend/resume, terminate.
  • How workspace data is persisted (files, snapshots/checkpoints).

State your assumptions, sketch the API, and describe the high-level architecture.

Hints

Hint 1

Start by anchoring the design on security: arbitrary code is hostile by default, so argue explicitly why containers sharing a kernel are or aren't acceptable before drawing anything else.

Hint 2

Separate the control plane (session state machine, scheduler, quotas) from the data plane (the hosts that actually run code), and decide who is allowed to touch what.

Hint 3

Think about streaming as a durable, sequenced log rather than a raw socket into the sandbox: how does a browser reconnect without losing or duplicating output?

Hint 4

Don't forget the boring parts that break sandboxes: the cloud metadata endpoint, east-west traffic between tenants, and long-lived credentials leaking into a guest.