KatInterview

Resilient Rate Control and Recovery for Distributed LLM Pipelines

System DesignModel answer
HardModel answerSystem Designsystem-designdistributed-systemsfault-tolerance

Last updated

Design a rate-aware ingestion engine and fault-tolerant checkpointing architecture for massive LLM DAG workflows facing strict provider quotas and ambiguous request failures.

A high-throughput distributed workflow platform executes multi-stage document processing pipelines (such as map-reduce summarization, entity extraction, structural analysis, and vector embedding) using external LLM provider APIs. Aggregate system volume reaches approximately 80 billion tokens daily. Workflows are modeled as Directed Acyclic Graphs (DAGs) where individual node tasks can run for 10 to 60+ seconds.

Upstream provider accounts strictly enforce limits on both Requests Per Minute (RPM) and Tokens Per Minute (TPM). Due to provider side-effects, dynamic context sizes, and transient service degradation, workers encounter HTTP 429 Too Many Requests responses, network timeouts, and late-stage node failures.

Architect a rate-aware dispatch layer and task recovery strategy that preserves tenant fairness, prevents retry thundering herds during rate-limit spikes, and eliminates duplicate execution costs following unexpected job terminations.


Core Areas to Address

1. Quota Enforcement & Dynamic Backpressure

  • Dual-Metric Accounting: Track concurrent request and token consumption across provider, account, model, and regional boundaries.
  • Lease Allocation: Design a distributed quota distribution model that minimizes central state store contention (e.g., Redis) under high worker concurrency.
  • Adaptive Multi-Tenant Backpressure: Handle HTTP 429 surges gracefully using backoff and jitter strategies while propagating backpressure upstream to protect tenant fairness.

2. Durable State Recovery & Ambiguous Execution

  • Granular Checkpointing: Implement deterministic caching boundaries for multi-stage document chunk operations so failures at stage $N$ do not re-execute completed stages $1 \dots N-1$.
  • Uncertain Request Reconciliation: Handle incomplete status returns (such as transport timeouts or HTTP 5xx responses) where provider side-effects or token billing may have already occurred.

Hints

Hint 1

Differentiate between prompt token counts (known prior to API dispatch) and completion token counts (known only after response arrival) using a pessimistic reservation and reconciliation model.

Hint 2

Avoid round-tripping to a central quota database on every single API call by utilizing a hierarchical lease system where workers request batch quota allocations for short time windows.

Hint 3

Construct deterministic cache keys for pipeline chunks using a composite hash of input data, prompt versions, model identifiers, and generation parameters.