Design the APIs of an executable notebook service
I was asked this
No reports yet. Sign in to say where you were asked it.
A system design interview question asked in Google's first round (coding), last asked Sep 2025. It tests api design, sandboxing and multi-tenancy.
Design a collaborative code notebook service: users edit notebooks in the browser, an execution service runs code, and a proxy fetches execution results and streams them back to the browser. Users can also upload a JAR of their own functions and run one by its fully qualified class and method name with arguments. Define the RESTful endpoints and the request and response schemas for uploading code, submitting executions, fetching logs and results, and cancelling. Then discuss sandboxing, dependency management, resource limits, concurrency and result streaming.
Requirements
- Functional: create, edit and share notebooks; upload a JAR artifact; submit an execution (
artifact_id,class_name,method_name,args); poll or stream its status, logs and result; cancel it; list past executions. - Non-functional: untrusted code is fully isolated from other users and from the platform; executions have CPU, memory, time and network limits; logs appear in the browser within about a second; the service handles many concurrent executions and survives worker crashes.
Clarifying questions
- Is collaborative editing real-time (several cursors), or save and reload?
- How long can an execution run, and how large can results and logs be?
- May user code reach the network or other services?
- Does a notebook keep state between cells (a live session), or is every run independent?
- How are dependencies of the JAR provided?
What a strong answer covers
- Endpoints, for example:
POST /artifacts(multipart upload, returnsartifact_idand checksum);POST /executionswith{artifact_id, class_name, method_name, args, timeout_s, idempotency_key}returning202 {execution_id, status: "queued"};GET /executions/{id}for status and result;GET /executions/{id}/logs?cursor=and a streaming variant (server-sent events or WebSocket);POST /executions/{id}:cancel; error codes for invalid class or method, limits exceeded and timeouts. - An execution state machine (queued, running, succeeded, failed, cancelled, timed out) stored durably.
- Execution path: a queue, a scheduler and workers that start a fresh sandbox (gVisor or Firecracker microVM, or containers with seccomp), load the JAR in its own class loader, and call the method with reflection.
- Dependencies: artifacts scanned and cached by checksum; a fixed base runtime; shaded or declared dependencies resolved at upload, not at run time.
- Limits: cgroup CPU and memory, wall-clock timeout, output size caps, no network by default; cancellation by killing the sandbox.
- Streaming: workers publish logs to a stream keyed by execution id; the proxy subscribes and forwards to the browser, resuming from a cursor after reconnects.
- Concurrency and sharing: per-user quotas and fair queuing; notebook edits through operational transforms or CRDTs if real-time, with execution results attached to cell versions.
Follow-ups
- Keep a warm interpreter per notebook so later cells see earlier variables. How does that change isolation and scaling?
- An uploaded JAR tries to mine cryptocurrency. What stops it, and how do you notice?
- Results are gigabytes. Where do they go, and what does the API return?
Where it's asked
- Google · First round: coding · Last asked Sep 202545 min · Coding in a Google Doc, no syntax highlighting or autocomplete · No AI
What it tests
api design · sandboxing · multi-tenancy
No official answer yet. Draw yours on the right; publish it and it shows under Community.
Nothing published yet. Publish your canvas and it shows here for others to open and remix.
