Scheduling Platform for Long-Running Multi-GPU Render Jobs
System DesignModel answerLast updated
Design a fault-tolerant, multi-tenant scheduler that places long, opaque, gang-scheduled GPU jobs on a 10,000-GPU fleet while keeping utilization high and recovering from node failures.
Problem
You are building the backend for a text-to-video generation product. Each request launches a heavy, black-box job on a specialized GPU host (for example, a machine with 8 high-end GPUs). A single job runs for roughly 2 to 45 minutes. GPUs are scarce and costly, so every idle GPU-minute matters and no tenant should be able to monopolize the fleet.
Design the platform that accepts requests, decides which hardware runs each one, supervises execution, and delivers the finished video.
Functional requirements
- Job lifecycle API: submit a job (model parameters, prompt, callback URL), poll its status, stream intermediate progress, and cancel it.
- Multi-tenant scheduling: several priority tiers (for example Enterprise vs. Free) plus fair-share behavior so that a heavy user cannot starve others.
- Gang scheduling: some jobs need several GPUs at once, either all 8 on one host or spread over several hosts. The whole set must be granted atomically.
- Checkpointing and resiliency: a host crash or thermal throttling mid-job must not throw away all progress.
Non-functional requirements
- Cluster-wide GPU utilization above 85%.
- 10,000+ GPUs and about 100,000 jobs per day.
- Node failures and network partitions must never corrupt job state or leave leaked (dangling) GPU allocations.
What to cover
- API and data model, including the job state machine (
QUEUED,ASSIGNED,RUNNING,CHECKPOINTING,COMPLETED,FAILED). - Architecture: gateway, scheduler, queueing layer, per-host agents, artifact storage.
- Scheduling strategy: fair queuing (e.g., Dominant Resource Fairness or a weighted deficit scheme), gang reservation, backfilling.
- Fault tolerance: heartbeats, health checks, preemption, checkpoint storage, and cleanup of stuck jobs.
State your assumptions and back-of-envelope numbers as you go.
Hints
Hint 1
Do the arithmetic first: jobs per day times GPU-hours per job versus GPUs times 24 hours. It tells you whether the hard part is request throughput or packing and wasted work.
Hint 2
Separate 'which job deserves GPUs next' (fairness) from 'where does it fit' (placement). That separation stops a large gang that cannot yet be placed from blocking everyone behind it.
Hint 3
For safety under failures, think leases with TTLs, monotonically increasing fencing tokens, and a single source of truth for GPU ownership that is changed only through atomic transactions.
Hint 4
Opaque jobs still expose natural checkpoint boundaries (such as denoising steps). Consider how checkpoints also make backfill and preemption cheap.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
1. Scale and assumptions
- Request rate: 100k jobs/day is about 1.2 jobs/s on average, perhaps 6/s at peak. Control-plane QPS is negligible.
- Capacity: assume an average job uses 8 GPUs for 15 minutes, i.e. 2 GPU-hours. Demand is about 200k GPU-hours/day against a supply of 10k x 24 = 240k, so roughly 83% load. An 85% utilization target leaves almost no slack, so packing quality and avoiding lost work dominate.
- Concurrency: about 1,000 jobs running at once on about 1,250 hosts. The queue is rarely empty.
- Polling: a few thousand active jobs polled every 5 s is a few hundred QPS. Fine.
Takeaway: the hard problem is placement correctness and utilization, not throughput. A strongly consistent, leader-elected scheduler is perfectly adequate.
Clarifying questions: can jobs checkpoint? Are runtime estimates available (derived from resolution, length, step count)? Do multi-host gangs need a specific interconnect zone?
2. API
POST /v1/jobs {model, prompt, params, gpus, callback_url, idempotency_key} -> {job_id}
GET /v1/jobs/{id} -> {state, progress, attempt, artifact_url?, error?}
GET /v1/jobs/{id}/events (SSE progress and previews)
POST /v1/jobs/{id}:cancel
Callbacks are at-least-once and signed; clients dedupe on job_id + state. Idempotency keys make submission retry-safe.
3. Data model
Use a transactional store (Postgres or Spanner). Every transition is a compare-and-swap on a version column.
- jobs: id, tenant, tier, state, version, resource request (gpus, hosts, topology), estimated runtime, current attempt, latest checkpoint URI, retry count.
- attempts: attempt id, job id, fencing token, host ids, start/end, exit reason.
- allocations: host, GPU mask, attempt id, lease expiry. The single source of truth for GPU ownership.
- tenants: weight, guaranteed GPUs, concurrency cap, consumed GPU-seconds.
- hosts: health (OK, SUSPECT, DRAINING, QUARANTINED), zone, last heartbeat.
State machine: QUEUED -> ASSIGNED -> RUNNING <-> CHECKPOINTING -> COMPLETED. Any active state may go to FAILED. RUNNING or CHECKPOINTING may return to QUEUED on preemption or node loss, carrying the latest checkpoint URI. Terminal states are immutable.
4. Architecture
- API gateway: auth, rate limits, idempotency.
- Job service: persists jobs and owns the state machine.
- Fair queue / admission: per-tenant queues; decides which job is next, knows nothing about machines.
- Placement binder: leader-elected, holds an in-memory view of allocations; decides where it fits, handles gangs, topology and backfill.
- Host agents: pull assignments, start containers, send heartbeats and GPU health metrics, execute checkpoint and kill commands.
- Artifact and checkpoint storage: object store. Model weights are cached on hosts; only per-job state (latents, step index, RNG and sampler state) is checkpointed.
- Reconciler: compares desired and actual state and reclaims leaks.
- Notifier: pub/sub feeding SSE and webhooks.
Splitting 3 from 4 prevents head-of-line blocking: an unplaceable 4-host gang holds a reservation while the binder keeps placing other work.
5. Scheduling
Fair share. Each tenant has a weight by tier (e.g., 10 / 3 / 1). Track decayed GPU-seconds consumed S_i and serve the backlogged tenant with the smallest S_i / w_i. With GPUs as the only contended resource, DRF collapses to weighted max-min fairness; add other resources (host RAM, disk) via dominant share. Express tier promises as a guaranteed floor (can preempt opportunistic work) plus weights above the floor.
Gang reservation. The binder chooses a host set (e.g., same interconnect zone) and writes all allocation rows in one transaction with a lease and fencing token. Partial holds never exist, so two gangs cannot deadlock each holding half of what the other needs. Agents must acknowledge within about 60 s or the reservation rolls back.
Backfill (EASY-style). The top blocked gang gets a reservation time T_r, the earliest moment enough GPUs free up based on estimated end times. Smaller jobs may use idle GPUs only if they are expected to finish before T_r or do not touch reserved GPUs. Backfilled jobs are marked preemptible; if an estimate is wrong, they checkpoint and requeue instead of being killed, so a bad estimate costs one checkpoint interval.
Packing. Place small jobs on already fragmented hosts; keep whole hosts and zones free for gangs; score placements by the fragmentation they leave.
6. Fault tolerance
- Heartbeats and leases: agents heartbeat every 5 s and renew a 30 s lease. Three missed beats mark a host
SUSPECT; lease expiry frees its GPUs and requeues the job from its checkpoint. - Fencing: every attempt has a monotonically increasing token, checked by agents, storage writes and state transitions. A partitioned zombie worker cannot complete a job or overwrite a newer checkpoint. An agent that cannot renew its lease kills its own container, preventing split-brain GPU use.
- Two-phase checkpoints: every N denoising steps (about every 3 minutes) write shards, then a manifest with checksums last. Only a complete manifest is valid; resume uses the newest valid one. Worst-case lost work is one interval; old checkpoints are garbage-collected after completion.
- Preemption: to honor a tier floor or a gang reservation, the binder asks the lowest-priority preemptible job to checkpoint, waits a bounded grace period, then kills it and requeues it with its checkpoint.
- Health: use GPU telemetry (ECC errors, thermal throttling, XID errors) to move hosts to
DRAININGorQUARANTINED, avoiding repeated failures on bad hardware. Cap retries and fail the job with a clear error after the cap. - Reconciler: periodically finds allocations without live attempts, attempts without allocations, and jobs stuck in
ASSIGNEDorCHECKPOINTINGpast a timeout, and repairs them. - Scheduler failover: the binder is stateless apart from the database. A new leader rebuilds its view from the allocations table; fencing prevents the old leader from committing.
7. Trade-offs and common mistakes
- Central scheduler vs. distributed: central is simpler and correct at this scale; shard by zone if it ever becomes the bottleneck.
- Frequent checkpoints reduce lost work but cost GPU time and storage bandwidth; tune the interval against failure rate.
- Common mistakes: designing for request QPS instead of utilization; incremental (hold-and-wait) gang allocation that deadlocks; no fencing, so zombies corrupt state; trusting runtime estimates without a preemption fallback; forgetting to garbage-collect checkpoints and reclaim leaked allocations.