KatInterview

Dependency-Aware Boot Orchestrator for a Many-Core Host

System DesignModel answer
HardModel answerSystem Designschedulingdagtopological-sort

Last updated

Design a scheduler that boots interdependent services on one multi-core machine as fast as possible, handling failures, resource limits, observability, and extension to a cluster.

Boot Orchestrator Design

A single host with M CPU cores must bring up a collection of services at boot. Some services need others to be up first, and these relationships form a directed acyclic graph (DAG).

Design an orchestrator that gets every service up in the shortest possible total time without ever starting a service before the things it relies on are ready.

In your answer, cover:

  1. Requirements and assumptions. What counts as "started"? How large is the graph? How do you treat failures?
  2. Interfaces and data structures. How do you track which services can run now (for example, remaining-dependency counters and ready queues)?
  3. Parallelism and ordering. How do you use the available cores fully, and which ready service do you pick first?
  4. Limits on concurrency and resources. CPU, memory, and network ports. How do you prevent a large service from blocking smaller ones?
  5. Failure handling. Timeouts, retries, backoff, and what happens to services that depend on one that failed for good.
  6. Observability. What do you expose so operators can see and debug a slow or stuck boot?
  7. Correctness. State the safety and liveness guarantees you provide and why they hold.
  8. Scaling out. How would the design change if services were spread across several machines?

Hints

Hint 1

Treat 'started' as 'passed a readiness probe', not 'process spawned'. Then track, per service, how many hard dependencies are still not ready; a service becomes eligible when that counter reaches zero.

Hint 2

Minimizing finish time with precedence constraints on M workers is NP-hard, so think about a list-scheduling heuristic. Ranking ready services by the longest remaining chain of estimated durations below them works well and has a known worst-case bound.

Hint 3

Strict priority ordering can leave a big service waiting at the head of the queue while cores sit idle. Consider backfilling that lets smaller work run only if it does not delay the head item's reservation.

Hint 4

For failures, separate retryable from non-retryable errors, add jittered exponential backoff, release resources while waiting, and propagate a 'blocked' status to all transitive hard dependents so nothing waits forever.