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
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
| Ask | Why it matters | A 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. |
Non-functional requirements
| Requirement | What 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
| Quantity | Working | Result | What 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
| Entity | What 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
| Endpoint | Notes |
|---|---|
| Checks that the caller may read the repository and that the image is on the allowlist, inserts the row in state |
| Both are state transitions, not synchronous actions: start moves |
| 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 |
| 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 |
The high-level design
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.
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?
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: Persistent volumes and snapshots
A concept that helps here: Job scheduling and delayed workA concept that helps here: Caching strategiesFailure 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?
Concepts this guide uses
Sources
- Gitpod (now Ona): We're leaving Kubernetes
- AWS Builder Center: Understanding AWS Firecracker
- Northflank: What is AWS Firecracker? The microVM technology, explained
- Google Cloud blog: How gVisor protects Google Cloud services from CVE-2020-14386
- Kubernetes documentation: Process ID limits and reservations
- EKS Best Practices Guides: Identity and Access Management
- GitHub Docs: Setting your timeout period for GitHub Codespaces
- Google Cloud documentation: How Cloud Shell works
- Amazon EBS documentation: Features and benefits of Amazon EBS volumes
- Amazon EBS documentation: What is Amazon Elastic Block Store?
- Martin Kleppmann: How to do distributed locking
- Kubernetes documentation: Nodes
- Amazon EC2 Auto Scaling documentation: Decrease latency for applications with long boot times using warm pools
- OneUptime: How to handle Istio control plane failures