Design a Cloud Workstation Platform for Engineers
System DesignModel answerLast updated
Design a service that gives engineers on-demand remote workstations they reach from a laptop, keep across stops and restarts, and have reclaimed automatically when idle.
Your company wants to stop engineers from building and running code only on their laptops. Design a cloud workstation platform: an engineer asks for a remote development machine, connects to it from their own laptop, keeps working over days or weeks, and the system reclaims resources once the machine is no longer needed.
The prompt is intentionally open. Deciding what the product has to do is part of the task. If you end up designing a generic container scheduler and never describe the experience an engineer has from request to cleanup, you have answered a different question.
What is expected
- Open by asking clarifying questions and writing down the scope you agree on (users, machine types, how people connect, what must survive a stop, time-to-ready targets, cost rules, what the machine may access).
- Describe the workstation lifecycle: create, connect, stop, resume, delete, and automatic idle shutdown.
- Present the architecture: API, control plane, placement, connection routing, storage.
- Explain how you make provisioning fast for large repositories and heavy toolchains.
- Cover isolation, authentication and secrets, network policy, quotas and cost control.
- Cover failure handling and the metrics that tell you engineers are being served well.
Logistics: treat this as a roughly 45-minute whiteboard conversation. No scale, latency or technology targets are given, so propose numbers and confirm them.
Hints
Hint 1
Before drawing anything, write the lifecycle as a state machine (requested, provisioning, running, stopping, stopped, deleted, failed) and ask what the engineer sees at each step.
Hint 2
Separate disposable compute from the durable workspace. If the home directory and repository checkout live on a volume or snapshot that outlives the machine, stop, resume, host failure and idle shutdown all become much easier.
Hint 3
Slow starts come from pulling images and cloning huge repositories. Think about prebuilt images, warm pools of capacity, and prebuilt workspace snapshots or cached repo mirrors so that a new box is a clone-on-write copy rather than a fresh checkout.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
1. Scope first
I would ask these questions and then state the assumptions back:
- Users and scale: assume 5,000 engineers, around 2,000 workstations existing and 1,000 running at peak.
- Machine shape: containers or microVMs for most people (4-16 vCPU, 16-64 GB RAM), with a small pool of large or GPU machines. Full VMs only when someone needs a custom kernel or nested virtualization.
- Access: SSH plus a local editor's remote extension as the primary path, and an optional browser IDE.
- Persistence: home directory, repository checkouts including uncommitted changes, and installed tools survive stop and resume. Running processes do not.
- Targets: new workstation ready in under 2 minutes at p90, resume in under 30 seconds, idle stop after about 60 minutes of inactivity.
- Governance: per-user quotas, cost attribution by team, access to source control, package mirrors and internal services, but no production data.
Non-goals: a general-purpose compute platform, CI, or production workloads.
2. Lifecycle
States: REQUESTED -> PROVISIONING -> RUNNING -> STOPPING -> STOPPED -> (RESUMING -> RUNNING) -> DELETING -> DELETED, plus FAILED. The user sees create, connect, stop, resume and delete, and the system adds idle stop and a retention-based delete (for example, delete workstations stopped for 30 days after a warning).
3. Architecture
- API and CLI/web UI: authenticated with company SSO. Calls are idempotent (client-supplied request ID) so retries do not create duplicates.
- Control plane: stores desired state per workstation in a transactional database (for example Postgres). A reconciler loop compares desired and actual state and drives transitions. This is the same pattern as Kubernetes controllers: level-triggered, retryable, and safe to restart.
- Scheduler/placement: picks a host in the compute pool based on region (close to the engineer and the repo mirror), machine size, and free capacity. Bin-pack for cost, but keep headroom for bursts.
- Compute pool: autoscaled hosts running microVMs or containers with strong isolation. Hosts report heartbeats and capacity.
- Storage: each workstation has a persistent block volume (or a layered volume) for the home directory and workspace. Compute attaches to it on start and detaches on stop.
- Connection gateway: engineers never reach hosts directly. They connect to a gateway (SSH over a proxy or a WebSocket tunnel). The gateway authenticates the user, looks up the workstation's current host in the control plane, and forwards traffic. An agent inside the workstation opens an outbound tunnel to the gateway, so no inbound ports or public IPs are needed and IP changes after resume are invisible to the user.
4. Fast provisioning
Slow starts are dominated by image pulls and repository clones.
- Prebuilt base images per team or stack, rebuilt nightly with dependencies baked in and cached on every host.
- Warm pool: keep a small number of pre-started, unassigned machines per common size (for example 5% of peak). Assigning one takes seconds; refill in the background.
- Workspace snapshots: a nightly job checks out the main branch of large repositories, builds caches, and snapshots the volume. A new workstation is a copy-on-write clone of that snapshot, then
git fetchto catch up. This turns a 20-minute clone into seconds. - Resume: reattach the existing volume to a warm host. If the old host has room, prefer it because its local caches are hot.
5. Idle detection and cost control
- The in-box agent reports activity: active SSH or IDE sessions, CPU above a threshold, terminal input, and an explicit "keep alive" flag for long jobs.
- After the idle window, warn the user, then stop. Stopping releases compute and keeps only storage, which is cheap.
- Quotas: max concurrent running boxes per user, max size, optional monthly budget per team. Show cost in the UI and send a report to team leads.
- Trade-off: aggressive idle timers save money but annoy people who run long builds. Make the timeout configurable within limits and make the warning visible.
6. Isolation and security
- One workstation per sandbox (microVM preferred over shared-kernel containers because users run arbitrary code and may have sudo).
- Per-user network policy: egress allow-list to source control, mirrors and internal services; no route to production networks. Default-deny, with a proxy that logs outbound traffic.
- Credentials: short-lived tokens issued from the user's identity (for example OIDC-based) rather than long-lived keys baked into images. Secrets are injected at start, never written into snapshots. Scan snapshots for secrets before they become shared templates.
- Volumes are encrypted and bound to the owner. Audit logs for create, connect and delete.
7. Failure handling
- Host failure: heartbeat loss marks the host dead. Because state lives on the volume, the reconciler reattaches the volume on another host and restarts. Users lose only running processes. Use a replicated volume or frequent snapshots to bound data loss.
- Stuck provisioning: per-step timeouts, bounded retries, then
FAILEDwith a clear reason and automatic cleanup of half-created resources. Never leave leaked volumes or machines; run a periodic garbage-collection sweep comparing the database with the cloud inventory. - Control plane outage: running workstations and existing sessions keep working because the data path (gateway and tunnel) does not depend on the reconciler. Only create, stop and resume are degraded.
- Capacity exhaustion: queue the request, show an honest ETA, and fall back to a smaller size or another region.
8. Observability
Track time-to-ready (p50/p90/p99, split by new vs resume), provisioning failure rate, warm pool hit rate, connection success rate and latency, idle-stop false positives (users who resume within minutes), utilization and cost per engineer, and snapshot freshness.
9. Common mistakes
- Designing a generic orchestration platform and skipping the user-facing lifecycle.
- Coupling the workspace to the host, so any failure loses work.
- Ignoring cold-start time for huge repositories.
- Exposing workstations with public IPs or storing long-lived credentials in images.
- No cleanup story, leading to leaked resources and runaway cost.
10. Possible follow-ups
Multi-region placement, GPU scheduling and fair sharing, sharing a workstation for pairing, prebuilding per-branch environments, and migrating running workstations during host maintenance.