CASE STUDY

Cloud Development Environment (Codespaces / Replit / DevBox)

6 min read·1,103 words·Advanced

How to use this case study

SDE-2 / Mid

Explain the workspace lifecycle (create, start, stop), running each workspace in an isolated container, and how the browser IDE connects to it.

SDE-3 / Senior

Go deeper on isolation (containers vs microVMs), persistent storage and snapshots, idle suspension, fast startup with pre-warmed pools, SSH and port forwarding.

Staff / Principal

Discuss multi-tenant security and identity propagation, scheduling on host fleets, quotas and cost, scheduled tasks, and reliable reconnect after host failures.


0) Problem Restatement

Design a platform that gives developers a development machine in the cloud, like GitHub Codespaces, Replit or a hosted notebook. A user opens a workspace (a project with its files and tools), edits code in a browser IDE or connects over SSH or a desktop IDE plugin, runs commands, builds and tests in isolation, and later comes back to find everything as they left it.

This was asked at OpenAI many times, with variations: SSH-based access with scheduled build/test tasks, a multi-tenant online IDE, and hosted notebooks.

Asked at: OpenAI — 7 candidate reports between Jan 2026 and Aug 2026.

1) Requirements

1.1 Functional

  • Create a workspace from a repo or template.
  • Start, stop, delete, and resume with files preserved.
  • Browser IDE (editor, terminal), plus SSH and IDE plugin access.
  • Run commands and servers, and preview web apps through forwarded ports.
  • Scheduled tasks (e.g., nightly build or test in the workspace).
  • Different machine sizes (CPU, RAM, GPU).

1.2 Non-Functional

  • Strong isolation: users run arbitrary code, and one tenant can never access another.
  • Fast start: under ~10–30 seconds.
  • Durable files: nothing lost when a machine dies.
  • Cost efficient: idle workspaces shouldn't burn compute.

1.3 Scale Estimates

  • 1M workspaces exist, 100K running at peak.
  • Each running workspace uses ~2–4 vCPU and 8 GB RAM → a fleet of thousands of hosts.
  • Storage: ~10 GB per workspace → 10 PB total (most of it idle, so cheap storage tiers).

1.4 API Design

  • POST /v1/workspaces { repo, template, machine_type }{ workspace_id }
  • POST /v1/workspaces/{id}/start / stop / DELETE
  • GET /v1/workspaces/{id}{ state, ide_url, ssh_host }
  • POST /v1/workspaces/{id}/tasks { cron, command }
  • The IDE connects via WebSocket to the workspace agent (terminal, file sync, language server).


2) High-Level Architecture

2.1 Overview

  • Control plane: the workspace API, the state machine (creating → starting → running → stopping → stopped), quotas and scheduling.
  • Scheduler: places a workspace on a host with capacity (bin-packing), using pre-warmed slots.
  • Host fleet: each host runs many workspaces as isolated microVMs (Firecracker) or hardened containers (gVisor).
  • Workspace agent inside each VM: terminal sessions, file operations, heartbeats and port forwarding.
  • Gateway / proxy: authenticates users and routes browser, SSH and port traffic to the right workspace.
  • Storage: a persistent volume per workspace (network block storage or snapshots to object storage).

2.2 Architecture Diagram

Architecture Diagram

flowchart LR
    U["Browser IDE / SSH / IDE plugin"] --> GW["Gateway - auth, routing"]
    GW --> AG["Workspace agent in microVM"]
    API["Control plane API"] --> DB[("Workspace DB")]
    API --> SCH["Scheduler"]
    SCH --> H["Host fleet - microVMs"]
    H --> AG
    AG --> VOL[("Persistent volume")]
    VOL -->|"snapshot on stop"| OS[("Object storage")]
    CRON["Task scheduler"] --> API

3) Key Flows

3.1 Start a workspace

  1. The API checks quota and sets the state to starting.
  2. The scheduler picks a host (right size, same region as the user) and ideally a pre-warmed microVM from a pool, which saves boot time.
  3. Attach the workspace volume. If stopped long ago, restore it from the object storage snapshot (lazy loading: fetch blocks on first access so startup is fast).
  4. The agent starts and heartbeats. The state becomes running, and the gateway registers the route workspace_id → host:port.
  5. The IDE connects over WebSocket through the gateway.

3.2 Idle and stop

If there's no activity (no keystrokes, terminal output or connections) for e.g. 30 minutes, stop the VM: flush and snapshot the volume, release the host slot, and set the state to stopped. Files are preserved, and compute cost goes to zero.

3.3 Scheduled tasks

The task scheduler wakes the workspace (starts it if stopped), runs the command via the agent, stores logs, and stops it again if it was stopped before.


4) Deep Dive A — Isolation and security

  • MicroVMs (Firecracker): each workspace gets its own lightweight virtual machine with its own kernel, which is much stronger isolation than plain containers, with fast boot (~100 ms). This is important because users run arbitrary code as root inside.
  • Network: default-deny between workspaces, egress through controlled NAT, and block cloud metadata endpoints.
  • Identity propagation: the workspace gets short-lived, scoped tokens (e.g., to push to that user's repo only), never long-lived secrets. Secrets are injected from a vault.
  • Resource limits: CPU, memory, disk and process quotas per workspace, so one workspace can't starve its neighbors.
  • Port forwarding: previews are served on unique URLs, private by default and requiring the user's auth.


5) Deep Dive B — Reliability and fast startup

  • Host failure: the agent's heartbeats stop, and the control plane marks the workspace failed/recovering and restarts it on another host from the latest snapshot. Unsaved in-memory state is lost, but files on the persistent volume survive (or, with network block storage, are fully intact).
  • Reconnect: IDE sessions reconnect automatically. Terminals run inside tmux-like session managers in the VM, so a network blip doesn't kill a running build.
  • Fast start: prebuilt images per template, dependency caches, prebuilds (run npm install when the repo changes, before anyone opens a workspace), and warm VM pools per region and machine size.
  • Capacity: bin-pack workspaces on hosts, overcommit CPU a little (most workspaces are idle), and autoscale the host fleet by demand and time of day.


6) Trade-offs & Alternatives

DecisionChoiceWhyAlternative
IsolationFirecracker microVMsStrong, fast bootContainers + gVisor: lighter, weaker than VMs
StoragePersistent volume + snapshotsDurable, cheap when idleLocal disk only: fast, lost on host failure
Idle costAuto-stop after inactivityBig savingsAlways on: simple, expensive
StartupWarm pools + prebuildsSeconds instead of minutesCold boot: slow

7) Common Follow-up Questions

  • "Hosted notebooks?" The same platform: the "workspace" runs a Jupyter kernel instead of an IDE. Kernels are stateful, so also store notebook outputs and allow kernel restarts.
  • "GPU workspaces?" A separate host pool, stricter quotas, shorter idle timeouts (GPUs are costly), and queueing when no GPU is free.
  • "How do you bill?" Meter running time × machine size, plus storage per GB-month.


8) Wrap-Up

A control plane manages each workspace's lifecycle and schedules it onto hosts, where it runs in its own microVM with a workspace agent. A gateway routes authenticated browser, SSH and port traffic to it. Files live on persistent volumes with snapshots, so idle workspaces can be stopped cheaply and restarted anywhere. Warm pools and prebuilds make startup fast, while microVM isolation, network rules and short-lived scoped tokens keep tenants safe.

More Case Studies

Practice with a Mock Interview

Apply what you learned in a live system design mock interview with our AI interviewer.

Start System Design Interview →