KatInterview

Design a GPU Job Scheduler for Text-to-Video Generation

System DesignModel answer
MediumModel answerSystem Designsystem-designjob-schedulerdistributed-systems

Last updated

Design an asynchronous GPU scheduling service for single-GPU text-to-video jobs, featuring weighted fair queueing, fault tolerance, and lease-based worker management.

Architect the backend infrastructure and scheduling engine for an AI text-to-video generation platform. Users submit textual prompts to generate short video clips, with each request dispatched to a dedicated GPU within a compute cluster.

Key Constraints & Requirements

  1. Single-GPU Execution: Each generation job runs exclusively on one GPU; distributed multi-GPU training/inference is out of scope for a single task. Tasks cannot be preempted or checkpointed mid-generation.
  2. Fair Resource Allocation: Multiple tenants (free, pro, enterprise users) share the compute fleet. The system must implement fair queueing based on consumed GPU compute time rather than task count to prevent resource monopolization.
  3. Resilience & Fault Tolerance: System components (workers, individual GPUs, state stores, and the scheduler instance) can crash at any point. The platform must guarantee eventual completion or terminal failure reporting without leaking resources or executing duplicated side effects.

Discussion Areas

  • System Architecture & Data Model: API endpoints, persistent job state management, worker execution flows, and output distribution.
  • Fair Queueing & Scheduling Logic: Algorithms for weighted fair sharing, handling idle user credits, managing per-tenant concurrency limits, and admission control under heavy traffic load.
  • Failure Modes & Edge Cases: Lease mechanisms, heartbeat strategies, handling poison-pill prompts, GPU hardware faults, split-brain mitigation, and scheduler recovery.

Hints

Hint 1

Base fairness on accumulated GPU execution time (e.g., Weighted Fair Queueing or Dominant Resource Fairness principles) rather than a simple round-robin or raw task count.

Hint 2

Decouple the durable job persistence layer (e.g., PostgreSQL/DynamoDB) from the fast in-memory scheduling queue (e.g., Redis/custom engine) to simplify state recovery.

Hint 3

Use short-lived, auto-renewing leases with fencing tokens so the system safely reassigns tasks when workers or GPUs crash.