Build a Cluster Scheduler for Generative Video Rendering on GPUs
System DesignModel answerLast updated
Design a fault-tolerant scheduler that places multi-node, all-or-nothing GPU jobs for a video generation platform, with topology-aware placement, tenant fairness and checkpoint-based preemption.
Context
You are designing the scheduling layer for a worldwide service that turns text prompts into video. Each request runs on several GPUs that must communicate over fast links (NVLink inside a node, InfiniBand between nodes). Runtimes range from about 30 seconds for quick low-resolution drafts to about 20 minutes for high-definition final renders. Demand regularly exceeds the available GPUs.
What the system must do
- Multiple tenants and tiers. Serve interactive previews, paid production renders and internal background fine-tuning, each with its own configurable SLA.
- All-or-nothing starts. A job needs its full set of GPUs (8 to 64, often across several nodes) running at the same moment. A partial allocation is useless.
- Preemption with checkpoints. Low-priority batch work must give way to interactive requests while wasting as little computation as possible.
- Fairness. During bursts, no single organization may monopolize the cluster.
Scale and targets
- 16,000 GPUs in 2,000 nodes of 8 GPUs, connected with InfiniBand.
- Up to 50,000 job submissions per hour at peak.
- Scheduling decision for an interactive draft in under 200 ms.
- Node and GPU health changes visible to the scheduler in under 1 second.
- Survives scheduler leader crashes and worker hardware failures without losing running or queued jobs.
What to cover in your answer
- API and data model: submit, inspect and cancel endpoints; how a job is represented (GPU count, topology preference, priority tier).
- Architecture: centralized versus two-level allocation, queueing, and how gang starts are made atomic.
- Topology-aware placement: handling NVLink domains, NUMA and rail-aligned InfiniBand.
- Fairness and preemption: the sharing algorithm (for example DRF or weighted fair queueing), the preemption protocol and where checkpoints are stored.
- Failure handling: stragglers, heartbeats, and re-queuing aborted jobs.
Hints
Hint 1
Convert the requirements into numbers first: 50k jobs/hour is only about 14 per second, so the hard part is placement quality and fairness, not decision throughput. Also compare estimated GPU demand with the 16,000-GPU supply.
Hint 2
A cluster of 2,000 nodes fits in one process's memory. Ask what that allows for gang scheduling compared with a two-level offer-based design, and how a big multi-node job avoids waiting forever behind small jobs (think reservations plus backfilling).
Hint 3
Treat preemption as a cost-minimization problem: how much work is lost since the last checkpoint, how important the victim is, and how often it has already been evicted. For failures, think about fencing tokens (allocation epochs), launch barriers with timeouts, and a replicated state store with a standby leader.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
1. Size the problem
- Supply: 2,000 nodes x 8 GPUs = 16,000 GPU-hours per wall-clock hour.
- Arrival rate: 50k jobs/hour is about 14/s on average; plan for 50-100/s bursts. That is a tiny decision rate, so the difficulty lies in which GPUs to pick, not in raw throughput.
- Demand: if the average job is 8 GPUs for 3 minutes, demand is about 20k GPU-hours per hour, above supply. Queueing, fairness and preemption are therefore central, not edge cases.
- Health traffic: 2,000 heartbeats/s at 1 Hz is trivial.
- Tiers: T0 interactive drafts (about 30 s, mostly 8 GPUs or fewer, under 200 ms to decide); T1 paid renders (up to 20 min, 8-64 GPUs, completion-time SLA); T2 internal fine-tuning (long, preemptible).
Takeaway: the whole cluster fits in the memory of one process, which makes a global view practical.
2. API and data model
POST /v1/jobs {tenant, tier, model_id, shape, topology, est_runtime, preemptible, idempotency_key}
GET /v1/jobs/{id} -> state, allocation, progress, last_checkpoint
DELETE /v1/jobs/{id} -> graceful cancel
Internal gRPC (scheduler <-> node agent):
Heartbeat(node_id, gpu_health, resident_models, running_jobs)
Launch(job_id, epoch, rank_map) / Checkpoint(job_id, deadline) / Kill(job_id)
- Job: id, tenant, tier, submit time, shape (e.g. 4 nodes x 8 GPUs, or a list of acceptable elastic shapes), topology constraint (
same_node | same_leaf | same_pod), model, estimated runtime, checkpoint interval, retry count, excluded nodes. - State machine: PENDING, ADMITTED, RESERVED, RUNNING, CHECKPOINTING, PREEMPTED (back to queue), then SUCCEEDED / FAILED / CANCELLED.
- Allocation: job, nodes, GPUs, and an epoch used as a fencing token.
- Node: leaf switch, pod, free-GPU bitmap, health, resident models, drain flag.
- Tenant: weight, guaranteed quota, burst limit, decayed GPU-seconds used.
Submissions carry an idempotency key so client retries do not create duplicates.
3. Architecture
Centralized allocator, not two-level. Offer-based designs make gang scheduling painful: frameworks hold partial offers while waiting for the rest, and two of them each holding half of what they need can deadlock. A single allocator that sees all nodes only ever commits complete placements.
Components:
- Admission service (stateless): validates, checks quotas, writes to a durable queue.
- Scheduler leader: in-memory cluster view, cycles every 50-100 ms plus an immediate fast path for T0.
- Replicated state store (etcd/Raft): jobs and allocations; a hot standby follows the log and takes over on leader loss.
- Health aggregator: merges heartbeats and GPU telemetry and pushes deltas to the scheduler, keeping staleness under 1 s.
- Node agents: start containers, report health, execute checkpoints locally.
Atomic gang start:
- Compute the entire placement on a snapshot.
- Commit it to the store in one transaction with a new epoch.
- Send
Launchto every node; ranks meet at a barrier. If any node has not acknowledged within about 5 s, release the whole allocation and put the job back at the head of the queue.
Avoiding starvation of large jobs. Small jobs can keep a 64-GPU job waiting indefinitely. Use EASY backfilling: the top blocked gang job receives a reservation on a specific node set at a future time, and smaller jobs may run in the gap only if their estimated runtime ends before the reservation starts. Video runtimes are predictable from resolution, frame count and denoising steps, so estimates are reliable.
4. Topology-aware placement
Model the fabric as a tree: GPU, node (NVSwitch), leaf switch (about 32 nodes), spine/pod.
- Jobs of 8 GPUs or fewer stay on one node.
- Pack 1/2/4-GPU jobs onto a few "fractional" nodes so whole nodes stay free for big gangs.
- Multi-node jobs get whole nodes in the smallest subtree that fits, ideally one leaf. On a rail-optimized fabric, GPU i on each node sits on rail i, so whole-node allocation keeps collective traffic rail-aligned and one hop away.
- Cross-spine placement only if the job allows it, and it is penalized.
- Inside a node, bind each process to the NUMA domain and NIC closest to its GPU.
Scoring: best-fit at leaf level (fewest free nodes that still fit) to limit fragmentation, a bonus when the model weights are already loaded, a penalty for evictions. Per-leaf free-node bitmaps make a search take microseconds per leaf.
5. Fairness and preemption
Queueing: strict priority T0 > T1 > T2, with a small guaranteed share per tier so none goes to zero. Inside a tier use weighted fair share on decayed GPU-seconds (priority = weight / decayed usage). Full DRF is unnecessary when GPUs are the single bottleneck; mention it as the generalization if CPU, memory or network become binding.
Quotas: each tenant has a guaranteed quota plus burst. Burst usage is flagged borrowed and is always preemptible, so idle capacity is used but nobody can lock others out.
Hitting 200 ms for T0: keep a warm pool of 5-10% of nodes with draft models loaded, so the fast path is a near O(1) lookup. When the pool runs low, the scheduler preempts and also grows the pool for the next cycle; preemption should rarely sit on the critical path.
Victim choice: minimize cost = work lost since last checkpoint + victim priority + a penalty for times already preempted (prevents thrashing the same job). Prefer fine-tuning jobs, which have cheap, frequent sharded async checkpoints.
Protocol:
- Send
Checkpoint(deadline about 10 s). - A diffusion job finishes its current denoising step (1-2 s).
- It saves latents, step index, RNG state and conditioning embeddings (hundreds of MB).
- Write to local NVMe first, then upload asynchronously to object storage.
- If the deadline passes, hard-kill and resume from the last periodic checkpoint.
Trade-off: graceful preemption costs seconds of latency but wastes almost nothing; hard kill is instant but loses up to one checkpoint interval.
6. Failures
- Node death: heartbeat missed for 3 intervals (about 3 s) marks the node suspect; the scheduler fences the allocation (bumps the epoch), kills the surviving ranks of the gang, and re-queues the job from its last checkpoint with the bad node excluded. Gangs fail as a unit, so never keep a partial job running.
- Stragglers: compare per-step time across ranks; if one rank is persistently slow (say 1.5x the median), treat the GPU as degraded, drain it and restart from a checkpoint on healthy hardware. Optionally add a hot spare for long T1 jobs.
- Leader crash: the standby acquires the lease, rebuilds the in-memory view from the store plus fresh heartbeats, and resumes. Fencing epochs ensure a zombie leader's commands are rejected by agents.
- Agent/network partition: an agent that loses contact with the scheduler past a lease timeout kills its local work, so a re-scheduled copy never runs alongside the old one.
- Retries: cap retry counts, back off, and move to FAILED with a clear reason after repeated failures.
Common mistakes
- Designing for throughput instead of placement quality.
- Allowing partial gang allocations or hoarding GPUs while waiting.
- Ignoring head-of-line blocking for large jobs.
- Splitting an 8-GPU job across nodes.
- Preempting without a cost model, causing thrashing.
- No fencing, so a stale scheduler or node runs duplicate work.