System Design Arena
System Design: Google Borg
Coordinate global fleets of machines to run mixed workloads with high utilization.
Case Study
Google Borg
Same conversation, diagrams, and wrap-up you expect—now framed with clearer scaffolding and iconography.
Prompt
Describe Borg, Google's internal orchestration system that runs billions of tasks across cells with quotas, priorities, and resilience.
Interview snapshot
- • Topic: Google Borg
- • Expected depth: 45 - 60 minutes
- • Focus areas: APIs, scale estimation, resilient architecture
- • Wrap-up: risk, monitoring, disaster recovery
Key takeaways
- • Accept job specs with resource requirements, priorities, constraints.
- • Scale: millions of tasks/minute, tens of thousands of machines per cell.
- • Job spec (task count, resources, priority, constraints).
🎙️ Interview mode
Practice this like a real interview
Don't read the answer first. Work the framework against the bare prompt, then compare against what the interviewer expected at each step.
Scorecard
What the interviewer is evaluating
Staff-level signal
Does the candidate separate scheduling (a constraint-solving control loop) from execution (kubelet-style agents), and reason about bin-packing versus failure domains?
🧠 Staff engineer judgment
The cluster must survive its own brain dying. If master downtime kills running workloads, the design is wrong — agents execute last-known-good state autonomously.
Calibration
The common (bad) answer
Job submitted → Scheduler → picks a free machine → runs it
❌ Why this scores poorly: "Picks a free machine" hides the entire problem: priorities, preemption, bin-packing, quota, failure domains, and what happens when the scheduler itself dies.
✓ What a strong answer adds
- Declarative desired state + reconciliation loops, not imperative placement.
- Priority bands with preemption: production evicts batch, batch reschedules.
- Bin-packing scored against spreading across failure domains — a stated tension.
- Master replicated with a consensus store; agents keep running when the master is gone.
- Quota as the admission-control layer that keeps the cluster honest.
Build it up
Step-by-Step Walkthrough
Borg is the interview where the 'users' are jobs and the 'traffic' is placement decisions. The journey runs from hand-assigned machines to a scheduler that keeps tens of thousands of machines busy without ever letting batch work hurt prod.
Naive: a spreadsheet of machines
Teams get machines: service A owns hosts 1–40, batch jobs SSH into whatever is free, and a wiki page tracks who owns what. Every org starts here, and it fails in a specific, quantifiable way: each team over-provisions for its own peak, so fleet-wide utilization sits painfully low while everyone still claims to be out of capacity.
Static assignment also cannot handle failure (a dead machine means a human re-deploys) or bursty batch demand. The fix is to stop giving teams machines and start taking job descriptions: 'run 100 replicas, each needing 2 CPUs and 4 GB, priority production' — and let a scheduler decide where they run.
The cell: one master, thousands of Borglets
Carve the fleet into cells of ~10K machines. Each cell runs a replicated Borgmaster — the API and source of truth — with state checkpointed through a Paxos-backed store (Chubby-style) so a master failover completes in seconds without losing what is running where. Elected leader serves; replicas shadow.
On every machine sits a Borglet agent: it starts tasks in containers, enforces cgroup-style resource limits, and reports health. Crucially, the master polls Borglets rather than letting ~10K agents stampede a freshly elected master — a small design choice that is really a thundering-herd answer, and worth saying out loud.
?Why does the master poll?
Push-based reporting from ~10K Borglets would flood a recovering master with a reconnect storm. Master-initiated polling lets it control its own load and pace state reconstruction after failover. Interviewers use this to test whether you think about restart behavior, not just steady state.
Scheduling is bin-packing with opinions
The scheduler runs feasibility then scoring: filter machines that satisfy the task's resources and constraints (kernel version, architecture, anti-affinity), then score survivors — packing efficiency, spreading replicas across failure domains, and preferring machines that already cache the task's packages so startup is fast.
At around ~1M placements/min (~16K decisions/sec) during churny periods, the scheduler cannot re-scan the world per task. It scores against cached cell state, evaluates identical tasks in a batch once (equivalence classes), and samples random feasible machines rather than exhaustively ranking all ~10K. Decoupling the scheduler from the master's request path keeps placement latency off the API.
Priorities, quota, and the preemption ladder
A full cell plus an incoming prod job is the moment the design earns its keep: every job has a priority band (monitoring > prod > batch > best-effort), and higher priority preempts lower — evicted batch tasks simply reschedule elsewhere. Prod jobs get killed for capacity approximately never; batch jobs treat eviction as routine, which is why batch fills the fleet fearlessly.
Quota keeps priorities honest: admission control checks a team's purchased quota at submit time, at that priority, so priority is not a free-for-all — you cannot bid everything to 'prod' without paying for it. Thousands of teams share a cell through this two-gate system: quota decides admission, priority decides survival.
!The SLO trap in mixed workloads
The obvious objection: doesn't batch-on-the-same-machine hurt prod latency? Answer with the mechanism — prod tasks reserve their limits, batch runs on reclaimed headroom, and the Borglet throttles or kills batch first the instant prod needs its reservation back.
Utilization: the whole point, plus the world above cells
Reserved-but-unused resources are the fleet's biggest waste, so Borg reclaims them: the Borglet measures actual usage, the master offers the headroom to batch work, and reclamation backs off when prod usage climbs. Mixing prod and batch in shared cells — rather than segregated clusters — is what pushes utilization high enough to matter at fleet economics scale; this is the headline result of the Borg paper.
Above the cell sits a thin global layer: per-cell autonomy for blast-radius containment, global tooling for cross-cell job submission, maintenance drains, and rolling updates that respect disruption budgets. Telemetry rounds it out — Borglets report every few seconds, tens of millions of metrics/min feeding dashboards and the health checks that auto-restart failed tasks. End by naming the descendants: this architecture, generalized, is Kubernetes.
Blueprint
Architecture Diagram
The narrated components above, laid out as an actual flow — so you can see how a request moves through the system, not just read a list of pieces.
Job submit
Job submit
Borg master
scheduler
selects machines
Borglet agent enforces
Borglet agent enforces limits
Borglet agent enforces limits, runs containers, reports health
Cell services
quota manager
quota manager, admission control, monitoring
Global control plane
Global control plane coordinates across cells
Global control plane coordinates across cells, handles failover
Priority/preemption ensures prod
Priority/preemption ensures prod jobs unaffected by
Priority/preemption ensures prod jobs unaffected by batch workloads
Flow Diagram
How the API maps to this flow
- 1
Job spec (task count, resources, priority, constraints). - 2
Quota API per team/service. - 3
Maintenance API for draining machines. - 4
Telemetry endpoints for job status, scheduler metrics. - 5
Integration with deployment systems (Borg submit).
?But why does this actually hold up at scale?
Assume 10K machines/cell, 64 cores each. Need ~1M task placements/min -> 16K/sec decisions.
Video walkthrough
Google Borg: billions of distributed Linux containers
Gaurav Sen · 18 min
The cluster manager Kubernetes descends from, explained from the original paper.
Work the prompt yourself first — guided practice grades your own answer step by step. Watching someone else design it feels like progress and teaches you far less.
Interview flow
Dialogue timeline
Interviewer
What problem does Borg solve?
Candidate
Schedule every Google service across thousands of machines, balancing priority workloads, maximizing utilization, providing automatic recovery.
Interviewer
Architecture overview?
Candidate
Clusters (cells) with Borg masters, Borglet agents on machines. Jobs submitted via Borg API, scheduler bin-packs tasks, enforces quotas, handles preemption.
Interviewer
Reliability and scale?
Candidate
Masters replicated with leader election, per-cell scheduling to avoid global bottleneck, quotas ensure fairness, monitoring detects failures and retries automatically.
Scoping
Requirements & trade-offs
Functional Requirements
- —Accept job specs with resource requirements, priorities, constraints.
- —Schedule tasks efficiently across machines.
- —Handle rolling updates, health checks, automatic restarts.
- —Enforce quotas and priorities, support preemption.
- —Expose telemetry/logging APIs and integrate with deployment tooling.
Non-Functional Requirements
- —Scale: millions of tasks/minute, tens of thousands of machines per cell.
- —High availability: master failover within seconds.
- —Isolation: cgroup-like limits, security sandbox.
- —Utilization: maintain high cluster utilization without impacting prod SLOs.
Blueprint
Architecture modules
Module 1
API/Concepts
- •Job spec (task count, resources, priority, constraints).
- •Quota API per team/service.
- •Maintenance API for draining machines.
- •Telemetry endpoints for job status, scheduler metrics.
- •Integration with deployment systems (Borg submit).
Module 2
Back-of-the-Envelope
- •Assume 10K machines/cell, 64 cores each. Need ~1M task placements/min -> 16K/sec decisions.
- •State tracking for millions of running tasks -> store in replicated metadata service (Chubby/Spanner).
- •Telemetry: each Borglet reports every few seconds -> tens of millions metrics/min.
- •Quotas: thousands of teams; maintain fairness via priority/preemption matrix.
Module 3
System Diagram Notes
- •Job submit -> Borg master -> scheduler -> selects machines.
- •Borglet agent enforces limits, runs containers, reports health.
- •Cell services: quota manager, admission control, monitoring.
- •Global control plane coordinates across cells, handles failover.
- •Priority/preemption ensures prod jobs unaffected by batch workloads.
Module 4
Design Playbook
- •Explain cells, masters, Borglets, job specs.
- •Discuss bin-packing, locality, priority scheduling.
- •Cover resilience: master failover, auto-restarts.
- •Mention integration with deployment pipeline and rollouts.
- •Highlight monitoring/logging, quota enforcement, security.