Design a Durable Work Orchestration Platform
Design a durable, tenant-fair workflow control plane for fast I/O and slow LLM tasks, with quota-aware dispatch, resumable progress, asynchronous waits and reliable stream-to-result commits.
Problem statement
For this exercise, assume clients publish versioned directed-acyclic workflow definitions and start runs through an API.
An edge may be conditioned on the terminal outcome of its upstream task: for example, task A routes success to B and terminal failure to C, and either selected branch can then satisfy the join that releases D.
The orchestration platform deterministically selects branches, marks unselected work as skipped, assigns ready tasks to heterogeneous workers, retries recoverable failures before treating an outcome as terminal, exposes run status, and supports cancellation.
Individual task code and business side effects are outside the platform boundary; delivery is at least once, so task handlers receive stable idempotency keys. Time-based recurring schedules are out of scope.
Define one authority for task state, branch selection, and dependency release so worker crashes, duplicate messages, and concurrent completions cannot corrupt a run.
Extend this same orchestration service to mixed I/O and LLM work. The workload has ten million predefined workflow definitions, about one million runs per day, and an average of ten tasks per run: eight I/O tasks and two LLM tasks. Typical I/O work takes 10–50 ms and LLM calls take 10–60 seconds.
Isolate slow work so it cannot consume the capacity needed by fast tasks. Account for provider requests-per-minute and tokens-per-minute quotas and HTTP 429 responses. Resume reusable partial task progress after failures without promising that an uncertain provider charge can always be avoided.
Support multi-day webhook or human-approval waits without holding a worker slot, enforce tenant fairness, and let clients observe token previews while downstream tasks depend only on a complete committed structured result.
For this exercise, assume validated definitions remain acyclic, conditional edges cannot create new cycles, and each logical task permits at most three retries after its initial attempt within a configured deadline.
Validate a new version before activation; cached validated versions may be admitted quickly, but arbitrary graph validation has no hardware-independent submillisecond guarantee. Token chunks carry an attempt epoch and increasing sequence number for reconnect replay.
Persist resumable wait state, and fence callbacks and stream/result commits against stale attempts or cancellation. Cancellation remains cooperative and cannot undo already performed external effects.
What to build
- A client can publish an immutable versioned DAG workflow definition.
- A client can idempotently start a workflow run and observe task and run status.
- The platform dispatches tasks only when the selected outcome predicates and join conditions are satisfied, and routes them to compatible workers.
- The platform retries recoverable task failures within policy and supports cooperative run cancellation.
- The platform deterministically routes terminal success or failure into the matching branch, skips unselected work, and lets downstream joins continue without waiting on an impossible branch.
- Dispatch fast I/O and slow LLM work without head-of-line starvation, using tenant-aware capacity and provider-quota admission.
- Persist reusable task progress and multi-day callback or approval waits; recover without holding worker slots while waiting.
- Expose ordered reconnectable token previews while releasing downstream work only from the committed complete result.
At scale
- For this exercise, assume 200 workflow starts per second at peak and up to 100 tasks per workflow.
- For this exercise, assume one million active task runs, with task durations ranging from seconds to six hours.
- For this exercise, target ready-task dispatch within five seconds at p95 while tolerating worker and queue-delivery failures.
- For this exercise, retain workflow and task status for 30 days; large task inputs and outputs live in external object storage referenced by immutable handles.
- The workload contains ten million workflow definitions and about one million daily runs with ten tasks each. For this exercise, use ten million daily tasks; peak dispatch is 5,000–10,000 tasks per second.
- Typical fast I/O tasks take 10–50 ms and LLM tasks 10–60 seconds. Approximately 200 TB of inputs and intermediate data flow daily; handle payloads through object references rather than queue or metadata copies.
- The workload uses about 80 billion tokens per day, roughly 925,926 tokens per second on average, subject to provider RPM/TPM quotas. About 100 million state/log transitions and 200 GB of change records occur daily.