KatInterview

Design a Task Execution Platform with Timing Guarantees

System DesignModel answer
MediumModel answerSystem Designdistributed-systemsschedulingreliability

Last updated

Build a distributed system to run scheduled and recurring tasks at scale with latency SLAs and full execution traceability.

Task Execution Platform Design

You are building a platform that executes user-submitted tasks either once at a specified time or repeatedly on a cron-like schedule. The platform must handle high throughput while guaranteeing that tasks begin running close to their scheduled time.

What the System Must Do

Core Capabilities:

  • Accept one-time tasks with a target execution time
  • Support recurring tasks using cron expressions (e.g., "every hour at :15")
  • Route tasks to a pool of execution nodes that report outcomes
  • Retry failed tasks with increasing delays between attempts

Performance and Reliability:

  • Throughput: Process at least 10,000 task submissions per minute
  • Timing SLA: Begin execution within 5 seconds of the scheduled moment for 99% of tasks
  • Durability: Guarantee every task runs at least once, even if nodes fail mid-execution
  • Traceability: Maintain a queryable history of every state change for compliance and troubleshooting

Additional Context:

  • Execution nodes are ephemeral and may restart or terminate at any time
  • Many recurring tasks fire at round clock times (top of the hour, start of the minute), creating bursty load
  • Tasks may take seconds to hours to complete

What You Should Cover

  1. API contracts for submitting tasks and querying execution history
  2. Data schema for persisting task definitions, execution state, and audit trails
  3. Architecture showing how tasks move from scheduled to running, including:
    • How the system identifies which tasks are ready to run
    • How execution nodes claim work without collisions
    • How the system detects and recovers from node failures
  4. SLA enforcement: How you measure and alert on timing violations

Explain your trade-offs and justify key choices.

Hints

Hint 1

Consider how you'll efficiently find tasks due in the next few seconds without scanning the entire database

Hint 2

Think about what happens when a worker crashes mid-execution—how do you prevent the task from being lost or running twice simultaneously?

Hint 3

Cron schedules create thundering-herd problems at round clock boundaries; address burst handling in your design