KatInterview

Build a Scheduler and Runner Platform for Automated Test Suites

System DesignModel answer
MediumModel answerSystem Designsystem-designdistributed-systemsscheduling

Last updated

Design a platform where teams declare automated tests, trigger or schedule them, run them on shared compute, and query status, logs, artifacts and history reliably at scale.

Problem

Your engineering organization wants a single internal platform that runs automated tests on demand and on a timetable. Design it.

The brief is deliberately loose. Start by asking clarifying questions, write down the assumptions you make (team count, run volume, kinds of compute), and then propose an architecture you can defend.

What your design should cover

  1. Test definitions. How a test is described, versioned and configured (image, command, resources, timeout, retry policy, parallelism, required hardware or labels).
  2. Triggering. How users start a run by hand, from a code-change event, or through a recurring schedule.
  3. Dispatch. How units of work reach executors, including heterogeneous ones (plain containers, GPU hosts, physical devices).
  4. Observability and storage. How status, live logs, artifacts and per-test results are stored and queried, including historical questions such as "is this test flaky?".
  5. Robustness. How you deal with crashed workers, retries, timeouts, cancellation, concurrency caps, fairness between teams, and growth in load.
  6. Interfaces. The public API, the worker-facing protocol and the core data model.

Expectations

  • Give rough capacity numbers and justify your storage choices with them.
  • Explain the state machine for a unit of work and what guarantees you offer (for example at-least-once execution).
  • Call out trade-offs and what you would change at 10x scale.

Hints

Hint 1

Separate the 'what to run' (an immutable, versioned definition) from 'one execution of it' (a run split into tasks). Every run should record the exact definition version it used.

Hint 2

Consider a pull model where workers lease tasks with an expiry and a fencing token, heartbeat while working, and have a reaper requeue expired leases. Ask what happens if a stale worker reports late.

Hint 3

Treat infrastructure failures and genuine test failures differently for retries, and decide where concurrency and fairness limits are enforced (hint: at lease time, per pool, team and definition). Use different stores for transactional metadata, blobs, and high-volume analytical results.