KatInterview

Design a Fair Multi-Tenant Image Enhancement Compute Service

System DesignModel answer
MediumModel answerSystem Designsystem-designdistributed-systemsscheduling

Last updated

Design a distributed compute platform for image processing using GPU workers, implementing dynamic weighted fair-queueing by compute time and resilient lease-based task execution.

You are designing the backend architecture for an asynchronous image upscaling SaaS platform. The core processing relies on a deep learning model running on a shared fleet of GPU accelerators. Each upscale task requires dedicated access to a single GPU for its entire execution (no GPU sharing or model sharding across multiple GPUs).

Operational Scale & Workload Profile

  • Traffic Volume: Peak throughput is 3,000 incoming requests per minute (~50 requests/sec).
  • Execution Time: Varies significantly based on requested scale factor (2x to 4x) and input image resolution:
    • Short tasks (small images, 2x): ~2 seconds.
    • Long tasks (4K images, 4x): 30 to 40 seconds.
    • Median task duration: ~5 seconds.
    • Average task duration ($\mu$): ~8 seconds.
  • Customer Tiers: Tens of thousands of users distributed across three service tiers: Free, Pro, and Enterprise.

System Requirements

  1. Request Lifecycle & Storage: Define the API endpoints, state transition workflow, persistent schema, and worker-scheduler orchestration model.
  2. Fairness & Scheduling Strategy: Design a scheduling algorithm that allocates GPU compute power fairly across tenants, considering that task durations are highly variable (task-count-based queuing is insufficient). Address edge cases such as idle burst protection and concurrency limits.
  3. Resilience & Fault Tolerance: Describe how the system handles worker crashes, GPU hardware failures, poison-pill tasks (jobs that crash the GPU worker), and scheduler failover without losing state or double-billing compute capacity.

Hints

Hint 1

Little's Law can help calculate the required GPU fleet size: L = λ * W.

Hint 2

Because job runtimes vary from 2s to 40s, fair scheduling should be based on estimated GPU execution time (accelerator-seconds), not raw task count.

Hint 3

Worker node polling (pull model) combined with time-bounded leases prevents deadlocks when worker nodes crash.