Design a dependency-aware job scheduler
I was asked this
No reports yet. Sign in to say where you were asked it.
A system design interview question asked in Databricks's system design round, last asked Jan 2026. It tests scheduling, dags and concurrency.
Design a job scheduler in which each job is a set of tasks with dependencies between them, a directed acyclic graph: a task may start only when every task it depends on has finished successfully. Many users submit jobs, independent tasks should run in parallel on a pool of workers, and the system must keep going when tasks or machines fail. Cover how dependencies are represented, how ready tasks are found and dispatched, state management, retries, recovery and observability.
Requirements
- Functional: submit a job as tasks plus dependency edges; reject a job whose graph has a cycle.
- Functional: run each task once its dependencies succeed; run independent tasks in parallel; show the status of every job and task; cancel a job.
- Functional: retry failed tasks per a policy; when a task fails for good, decide what happens to the tasks that depend on it and to the rest of the job.
- Non-functional: thousands of concurrent jobs and many thousands of tasks; scheduler failover without losing or duplicating work; tasks may run for hours.
Clarifying questions
- How big are jobs (tens of tasks or tens of thousands) and how long do tasks run?
- Are jobs submitted once or on a recurring schedule (cron)?
- Must tasks run exactly once, or is at-least-once with idempotent tasks acceptable?
- When a task fails for good, should independent branches keep running?
- Are there resource limits, priorities or per-user quotas?
What a strong answer covers
- Validation on submit: a topological sort (Kahn's algorithm) that detects cycles, and storing tasks and edges with a count of unfinished dependencies per task.
- Finding ready tasks without rescanning the graph: when a task succeeds, decrement each dependent's count and enqueue the ones that reach zero, in one transaction with the state change.
- Task states (pending, ready, running, succeeded, failed, skipped, cancelled) and job states derived from them.
- Dispatch: a ready queue, workers that pull with a lease and heartbeat, and lease expiry to detect dead workers; priorities and quotas applied at dispatch.
- Failure handling: retries with backoff, then marking downstream tasks skipped while independent branches finish; a policy to fail fast or let the rest run.
- The scheduler's own state in a durable store, with several scheduler instances partitioned by job or using leader election, so a crash loses nothing.
- Observability: per-job progress and critical path, queue wait time, task duration, retry and failure rates, stuck tasks.
Follow-ups
- Rerun only the failed task and everything downstream of it, keeping earlier results.
- A task produces a large output its dependents need. Where is it stored and how is it passed?
- A job of 100,000 tasks is submitted. What breaks first?
- Add recurring jobs that must not overlap with the previous run.
Where it's asked
- Databricks · System design · Last asked Jan 202660 min · Design discussion, often written in a Google Doc rather than on a whiteboard
What it tests
scheduling · dags · concurrency · fault tolerance
No official answer yet. Draw yours on the right; publish it and it shows under Community.
Nothing published yet. Publish your canvas and it shows here for others to open and remix.
