KatInterview

Critique a GPU Inference Service Design and Schedule Mixed Models

System DesignModel answer
MediumModel answerSystem Designgpu-inferencebatchingload-balancing

Last updated

Analyze a design for a batched GPU inference API, identifying flaws in batching, load distribution, caching, and admission control, then calculate capacity needs and schedule heterogeneous models.

You're reviewing a technical proposal for a GPU-powered prediction service. Instead of designing from scratch, your task is to evaluate an existing architecture, identify its weaknesses, reason about its capacity, and solve a multi-model scheduling challenge.

The Proposed Architecture

HTTP Prediction Service

Target: handle 10,000 requests/second at peak traffic.

Architecture:
1. Round-robin L4 load balancer distributes incoming POST /predict requests
   across independent API server instances.
2. Each API server maintains its own request buffer. Once B requests accumulate
   (where B matches the model's batch size limit), the server dispatches them
   to a GPU worker. Each batched inference operation requires 100 ms.
3. An in-memory response cache uses the complete request body as the cache key,
   positioned before the API servers to avoid redundant GPU computation.
4. Clients implement timeout-based retry logic without unique request tokens.
5. No per-client throttling exists; all incoming requests enter the queue.
6. Capacity formula: each GPU processes B requests every 100 ms, therefore
   the fleet requires exactly 10,000 / (10 × B) GPUs total.

Your Tasks

Task 1: Identify Design Weaknesses

Review the architecture and pinpoint its critical problems. For each issue, describe:

  • The concrete failure mode it creates under real traffic patterns
  • A practical remediation approach
  • Your priority ranking: which 2-3 issues are blocking concerns?

Focus on: batching behavior at different load levels, how load distribution affects batch formation, cache utility given actual traffic, retry handling, and capacity protection.

Task 2: Capacity Analysis

Given the 100 ms batch time and 10,000 QPS target:

  • Calculate the GPU count using the document's formula as a function of B
  • Explain why actual throughput falls short of the theoretical maximum
  • Describe how you would size the fleet differently, and why
  • Contrast realtime serving requirements with offline batch processing

Task 3: Heterogeneous Model Scheduling

A single pool of 8 GPUs must now serve two different models with identical latency requirements:

  • Large model: requires all 8 GPUs simultaneously for one batch
  • Small model: requires 1 GPU for one batch

Proposed scheduling approach: maintain separate queues for each model, allocate GPU time proportionally to each model's request rate, and prioritize the large model when request rates are equal.

Evaluate this proposal. Provide:

  • The capacity constraint for meeting both models' latency targets
  • Risks in the proposed approach (particularly for the large model)
  • Your recommended scheduling policy with latency protection for both
  • Assessment of the proportional allocation and tie-breaking rule

Clarifying Questions to Consider

  • What latency SLA applies, and is this user-facing or batch processing?
  • How much do request sizes vary, and does batch time depend on them?
  • Are predictions deterministic or sampled?
  • Is traffic uniform or bursty? Single-tenant or multi-tenant?
  • Single model deployment or multiple models per server?

Hints

Hint 1

At low traffic, how long does each server wait to fill a batch? At high traffic with independent queues, what happens to batch efficiency?

Hint 2

The cache key is the full request body. How often will identical requests arrive close enough in time for a cache hit to matter?

Hint 3

Without request IDs, what happens when a client retries after timeout? Consider the resource cost when many clients retry simultaneously.