KatInterview

Designing a Scalable Mixed-Latency Multi-Tenant Workflow Engine

System DesignModel answer
HardModel answerSystem Designsystem-designdistributed-systemsqueues

Last updated

Architect a multi-tenant orchestration engine handling high-throughput fast I/O tasks alongside long-running LLM tasks with tenant fairness and tiered state storage.

Design an enterprise-grade, multi-tenant workflow orchestration platform capable of executing Directed Acyclic Graphs (DAGs) containing two distinct categories of tasks: short fast I/O tasks (e.g., API calls, DB reads) and long-running generative AI / LLM tasks.

System Specifications & Parameters

Metric / ParameterValue
Total Registered Workflow Definitions10 million
Active Workflow Executions (Runs)~1 million / day
Average Graph Composition10 tasks total (8 Fast I/O, 2 Slow LLM)
Stated Daily Task Execution Volume~100 million tasks / day
Peak Global Task Dispatch Rate5,000 – 10,000 tasks / second
Fast I/O Task Execution Latency10 ms – 50 ms
Slow LLM Task Execution Latency10 s – 60 s
Daily Intermediate Data & File Artifacts~200 TB / day
State Transition Audit Logs~100 million records (~200 GB) / day

Note on Discrepancies: The total runs per day ($1\text{M}$) times average tasks per run ($10$) yields $10\text{M}$ tasks/day, whereas the separate metric reports $100\text{M}$ tasks/day. Treat this discrepancy as an intentional data ambiguity to address during capacity planning.


Key Requirements

Part 1: Capacity Sizing & Latency-Aware Task Dispatching

  • Reconcile the discrepancy in task execution volume estimates and calculate average vs. peak throughput requirements.
  • Calculate total concurrent execution slots required for both Fast I/O and Slow LLM tasks under peak load.
  • Design an execution queue and worker isolation model that ensures slow, blocking LLM calls never starve fast I/O tasks.

Part 2: State Persistence, Storage Tiering & Artifact Management

  • Design the storage architecture for workflow definitions, active run state transitions, append-only execution logs, and large task artifacts.
  • Propose schema models, primary/partition keys, and query patterns that allow low-latency execution state checks without scanning historical logs or retrieving heavy payloads.

Part 3: Multi-Tenant Isolation & Fair Scheduling

  • Architect fairness mechanisms to handle bursty multi-tenant submissions (e.g., a single tenant enqueuing 500,000 workflows simultaneously).
  • Prevent downstream rate-limiting (e.g., LLM vendor token limits) while maintaining high overall system utilization through capacity borrowing.