Skip to content

How to design a cloud IDE

The first sections are free. The deep dives, level expectations and quiz are part of Pro.

On this page
Asked at
Practice this question

The problem

A cloud IDE runs each developer's project on the provider's machines and shows an editor and a terminal for it in the browser. The question is about the platform behind that screen: a control plane that creates, places, stops and resumes workspaces, a fleet of hosts that run them, a gateway that connects each browser to the right host, and storage that keeps the files when a host goes away. Two facts shape the answer. Strangers run arbitrary code as root on shared machines, so the sandbox around each workspace comes first. And compute spent on a workspace nobody is typing in is wasted, so stopping idle ones and bringing them back quickly decides both the bill and how the product feels.

Clarifying questions

AskWhy it mattersA typical answer

How many users and workspaces are there, and how many run at the same time?

The count of running workspaces sets the fleet size and how many sandboxes share a host; the share that opens in the same hour sets how hard the morning start is.

Tens of thousands of users with one workspace each. Many are busy at once, and most open theirs when the workday begins.

Can a user run anything inside the workspace, including as root, and install what they like?

If the answer is yes, the workspace is untrusted code on your machines, and the strength of the sandbox becomes the first design decision rather than a detail.

Yes. Developers expect root, package installs and their own tools. Treat the code as untrusted.

When someone comes back after days, do they expect their files, or their running processes too?

A resume that restores files lets you stop a workspace and bring its disk back anywhere. Keeping processes alive means memory snapshots or a workspace that is kept running, which changes storage and cost.

Files intact. A build that was running on Friday can be gone on Monday.

Is a workspace one person's, or do several people edit in it live?

Live co-editing of one file is a separate problem with its own algorithms. Settling it keeps the round on the platform.

One user per workspace. Live collaboration is out of scope.

Do workspaces reach the internet, and does anything reach them, like a web app the developer is previewing?

Outbound access decides what egress controls you need. Inbound previews decide what the gateway must proxy besides the editor and terminal.

Outbound access to fetch packages, with controls. Inbound traffic arrives through the gateway on authenticated preview URLs.

How quick does a start or a resume need to be?

A target of seconds pushes you toward warm hosts, cached images and restoring from snapshots in the background; a target of minutes lets the design stay simpler.

Not given as a figure. Propose one: a resume should feel like opening a laptop, so aim for seconds for a stopped workspace and accept longer for a brand-new one, and say that the target is yours.

The requirements menu

RequirementScopeWhy

Create a workspace and open it in the browser

Core

The entry point. It forces a control plane that records the workspace, a scheduler that picks a host, and a gateway that gets the browser to it.

Edit the project’s files

Core

The editor runs against the workspace's disk, so the files must be on the host that runs it and must follow it to another host.

Use a terminal, and build and run code inside the workspace

Core

This is what makes the workload untrusted: whatever the user types runs on your machine. It drives the sandbox choice and the quotas.

Stop a workspace and resume it later with its files intact

Core

The lifecycle that lets you give idle compute back. It needs storage that outlives the host and a resume path that can land on any machine.

Preview a web app running in the workspace on a URL

Optional

Worth taking if time allows: the gateway already proxies the terminal, so a preview is one more authenticated route to a port inside the sandbox. It also raises who may open the URL.

Prebuild the workspace image from the repository so the first start is fast

Optional

A real product feature, since cloning and installing dependencies dominates a cold start. Leave it unless asked; the resume path matters more to this round.

Snapshot a workspace on demand and share or fork it

Optional

Falls out of the snapshot machinery you already need for stops. Name it, and leave it unless the interviewer wants to talk about storage.

Resume with running processes intact as well as files

Optional

Memory snapshots of a micro VM make this possible, but they are large and slow to move between hosts. Leave it unless asked; restoring files on resume is what this design offers.

Run workspaces in several regions close to users

Out of scope

Terminal latency matters, but a second region adds a fleet, a scheduler and a storage tier to run. Say the design is per region and that a workspace lives in one of them.

GPU workspaces

Out of scope

A likely follow-up: far fewer GPUs than users means a separate host pool, reservations and a stricter idle timeout. Park it unless raised.

Several users editing one file live (that is the Google Docs question)

Out of scope

Conflict-free editing is its own round. Keep one user per workspace.

Language servers and editor plugins

Out of scope

They run inside the workspace like any other process, so the platform does not need to know about them.

Billing

Out of scope

Metering running time is a consumer of the state changes you already record. Mention that each start and stop is an event, and move on.

Non-functional requirements

RequirementWhat it forces

Each tenant’s code is isolated from every other tenant and from the platform

One tenant per sandbox, and a sandbox boundary that does not depend on the shared host kernel holding: a micro VM per workspace, or a hardened container with a clear statement of the risk. Network rules between sandboxes, egress under control, the cloud metadata service unreachable from inside, and the host agent on a management network the workspace can't see.

Workspace files survive a restart or the loss of a host

The files can't live on the host's local disk by themselves. They sit on a network volume or are snapshotted to object storage, and the design states how much work a user can lose if a host dies between snapshots.

Idle workspaces give their compute back

An idle detector that watches terminal and editor activity, a stop path that snapshots and frees the host, and a resume path quick enough that stopping is acceptable to users.

Starting or resuming a workspace is quick

Hosts kept warm with the common images cached, a volume attach or snapshot restore whose time is measured and bounded, since attach timing is known to be unpredictable, and a scheduler that handles a burst of starts at the beginning of the workday without queueing everyone behind one slow step.

Estimates

QuantityWorkingResultWhat it sizes

Working figures for the fleet

Take 50,000 workspaces as a working figure for "tens of thousands". Assume 40% are running in the busiest hour: 50,000 × 0.4 = 20,000

50,000 workspaces, about 20,000 running at the peak

The fleet and the storage; both are assumptions stated out loud, which is the point.

Hosts at the peak

Assume 4 GB of memory per workspace and 256 GB hosts: 256 ÷ 4 = 64 slots, call it 60 after host overhead. 20,000 ÷ 60 ≈ 333 hosts

About 333 hosts running, all of them needed by the time the morning surge ends

The fleet, and how big a warm pool has to be if the surge must not wait for new machines to boot. Micro VMs make overbooking memory harder than containers do, so treat these slots as firm.

Memory the micro VM boundary costs on a host

Vendor figure: Firecracker reports less than 5 MiB of overhead per micro VM. 60 × 5 MiB = 300 MiB; 300 MiB ÷ 262,144 MiB (256 GB) ≈ 0.1%

About 300 MiB a host, about 0.1% of its memory

Why the cost of a kernel per tenant is in start time and lost overcommit, not in memory.

Starts in the morning surge

Assume most of the 50,000 open within an hour: 50,000 ÷ 3,600 s ≈ 14 starts a second averaged. Assume half arrive in a 15-minute window: 25,000 ÷ 900 s ≈ 28 a second

Roughly 14 to 28 starts a second, each a placement, a volume attach, a boot and a route update

The scheduler, the volume attach rate and the cap on starts in flight.

Storage for workspace files

Assume 10 GB of project files and tools per workspace: 50,000 × 10 GB = 500 TB. With 20,000 running on volumes and 30,000 stopped as snapshots: 200 TB on volumes, 300 TB in object storage before compression

About 500 TB in all, with about 300 TB of it in the cheaper object tier

The storage bill and why stopped workspaces move to object storage instead of keeping a volume each.

Time to restore a workspace

Assume a restore stream of 100 MB/s per workspace. A full 10 GB snapshot: 10,000 MB ÷ 100 MB/s = 100 s. With the base image already cached on the host and just 1 GB of the user's changes to fetch: 10 s

About 100 s for a full restore against about 10 s for changes on top of a cached image

Why images are cached on hosts and snapshots hold the user's layer, not the whole disk.

What stopping idle workspaces saves

A workspace used 8 hours on each of 5 weekdays runs 40 hours of the week's 168: 40 ÷ 168 ≈ 24%. Running around the clock costs 168 ÷ 40 ≈ 4.2 times as much compute

Stopping idle workspaces cuts compute to about a quarter of running around the clock

The idle reaper's value, and the money that pays for a warm pool.

An idle timeout to pick

Vendor figures: GitHub Codespaces stops after 30 minutes idle by default, settable between 5 and 240 minutes, with a maximum lifetime of 12 hours; Google Cloud Shell discards its VM after a period of inactivity while keeping the home disk

A default around 30 to 60 minutes, user-adjustable

The idle reaper's threshold: long enough that a coffee break doesn't cost a resume, short enough that the savings above are real.

Core entities

EntityWhat it holds

Workspace

One row per workspace: who owns it, what image it runs, what state it is in, and which host and volume it currently has.

Volume or disk snapshot

Where the files are right now: a network volume attached to a host, a snapshot in object storage, or both while a stop is in progress.

Host

A machine in the fleet: what it can hold, what it is holding, and when it last reported in.

Session

One browser's live connection to a workspace: who, which workspace, and which gateway node is carrying the bytes.

The API

EndpointNotes

POST /workspaces { repo, image } → { workspace_id }

Checks that the caller may read the repository and that the image is on the allowlist, inserts the row in state creating, and returns at once; cloning and the first boot happen in the background. Take an idempotency key so a retried request doesn't make a second workspace.

POST /workspaces/{id}/start and POST /workspaces/{id}/stop

Both are state transitions, not synchronous actions: start moves stopped to starting and asks the scheduler for a host; stop moves running to stopping, tells the host agent to flush and shut the sandbox down, then snapshots the volume. Start on a running workspace and stop on a stopped one are no-ops, so clients can retry freely. Owner only.

GET /workspaces/{id} → state and connect URL

The connect URL points at the gateway rather than at a host, and carries a short-lived signed token for this user and workspace. Clients poll this while the state is starting; the URL is meaningful once the state is running.

WS /workspaces/{id}/terminal: keystrokes in, output out

The gateway validates the token, confirms that the caller is the workspace's owner, looks up the host and proxies the WebSocket to the host agent, which attaches it to a shell inside the sandbox. Each keystroke and each byte of output refreshes last_active_at, so the idle reaper doesn't stop a workspace that is being used.

The high-level design

createplacestartrunsterminalBrowserControl planeWorkspaces DBSchedulerHost agentMicro VM

Step 1 of 4

A workspace service, a scheduler and hosts that run sandboxes

Start with the control plane and the fleet. A workspace service owns the API and a database of workspaces and their states. When a start arrives, a scheduler picks a host with a free slot and tells that host's agent to boot a sandbox for the workspace: one tenant per sandbox, and a micro VM rather than a plain container, so a user who is root inside has a kernel of their own to attack rather than the host's. In this first cut the browser's terminal connects straight to the host, which is the problem the next step fixes.

editorcreateidleplacestartwarmrouterunscachedsnapshotmountegressBrowserGatewayControl planeIdle reaperWorkspaces DBSchedulerHost agentWarm poolMicro VMImage cacheObject storeNetwork volumeInternet
The whole design

What breaks first

The deep dives

Isolating tenants. Users run arbitrary code as root inside their workspaces, and strangers share hosts. What keeps one workspace out of another's, and out of the platform?

A concept that helps here: Sandboxing untrusted codeA concept that helps here: Multi-tenant isolationA concept that helps here: Authorization models

Workspace state and resume. A user shuts the laptop on Friday and comes back Monday. Where were the files over the weekend, what did it cost to keep them there, and how does the workspace come back on a different machine?

A concept that helps here: Job scheduling and delayed workA concept that helps here: Caching strategies

Failure modes. A host running dozens of workspaces dies at midday. How does the platform find out, what do its users see, what brings them back, and what stops a workspace from running on two hosts at once?

A concept that helps here: Heartbeats and presenceA concept that helps here: Distributed locks and leasesA concept that helps here: Backpressure and load shedding

Concepts this guide uses

Sources

  1. Gitpod (now Ona): We're leaving Kubernetes
  2. AWS Builder Center: Understanding AWS Firecracker
  3. Northflank: What is AWS Firecracker? The microVM technology, explained
  4. Google Cloud blog: How gVisor protects Google Cloud services from CVE-2020-14386
  5. Kubernetes documentation: Process ID limits and reservations
  6. EKS Best Practices Guides: Identity and Access Management
  7. GitHub Docs: Setting your timeout period for GitHub Codespaces
  8. Google Cloud documentation: How Cloud Shell works
  9. Amazon EBS documentation: Features and benefits of Amazon EBS volumes
  10. Amazon EBS documentation: What is Amazon Elastic Block Store?
  11. Martin Kleppmann: How to do distributed locking
  12. Kubernetes documentation: Nodes
  13. Amazon EC2 Auto Scaling documentation: Decrease latency for applications with long boot times using warm pools
  14. OneUptime: How to handle Istio control plane failures
Sign in to report a mistake