KatInterview

Build a Pipeline Execution Platform for Thousands of Tenants

System DesignModel answer
HardModel answerSystem Designsystem-designdistributed-systemsscheduling

Last updated

Design a scalable, multi-tenant CI/CD system that runs Git-triggered job pipelines with strong isolation, fair scheduling, live log streaming, and per-tenant billing.

The Problem

You are the founding engineer on a cloud-hosted pipeline execution service. Software teams connect their source repositories, drop a YAML workflow file into each repo, and the platform automatically runs those workflows whenever code is pushed. The service must handle thousands of independent organizations simultaneously, keep every organization's workload fully isolated from every other, and stay highly available under bursty load.

Walk through your architecture from start to finish, then go deep on each numbered area below.


What one pipeline run looks like

A developer pushes a commit. The platform receives a notification, reads the workflow file pinned to that exact commit, compiles it into a graph of jobs, executes those jobs on isolated compute, streams output to the developer's browser in real time, and records resource consumption for billing at the end.


Areas to cover

1. Ingesting push notifications The platform receives push events from SCM webhooks or an internal service API. Each event carries a repository ID, a commit SHA, a branch name, and a change summary. How do you authenticate callers, validate payloads, deduplicate repeated deliveries, and persist events durably before acknowledging them? How do you fan work out to downstream processors? What happens when those processors fall behind the arrival rate?

2. Fetching and compiling the workflow definition Every repository stores a YAML pipeline definition at a fixed path. How do you retrieve that file at the exact pushed commit (not the current branch tip)? How do you validate its schema, expand matrix build dimensions, construct the job dependency graph, detect cycles, and produce an immutable compiled plan that makes future re-runs reproducible?

3. Run and job lifecycle Define the state machine for a run and for each individual job. Explain how you handle job dependencies, conditional execution, matrix jobs, retries with exponential backoff, per-job timeouts, cancellation requests, idempotent state transitions, and manual approval gates.

4. Scheduling work fairly across tenants When thousands of organizations have queued jobs, how do you decide what to dispatch next? Describe your fairness mechanism, how you enforce per-tenant concurrency caps and minute quotas, and how you prevent a single large organization from crowding out smaller ones.

5. Compute runners and workload isolation Compare available runner form factors: shared containers, microVMs (e.g., Firecracker), and dedicated VM pools. How does a runner claim a job, clone source at the right commit, receive narrowly scoped secrets, restore build caches safely, and report results? How do you detect and recover from a runner that dies silently mid-job?

6. Live log and status streaming Developers expect to watch job output as it is produced. Trace the path from bytes written on a runner through to text appearing in a browser tab. How do you support late-joining viewers, client reconnects, and long-term log retention?

7. Storage systems Name each storage system your design relies on (relational DB, object store, message bus, cache, secret store) and describe exactly what it owns and why that system was chosen for that responsibility.

8. Tenant isolation, access control, and secret handling How do you prevent one tenant's jobs, logs, and secrets from being accessible to another? Describe your RBAC model, how secrets are scoped and injected into jobs, and how you enforce security policy at runtime.

9. Scaling the system How does the runner fleet grow and shrink in response to queue depth? How do you scale control-plane services horizontally? How do you shard the scheduler as dispatch throughput grows? How do you scale the metadata database?

10. Metering usage and billing tenants Which resource dimensions do you meter (compute time, storage, egress)? How do you collect, aggregate, and expose that data? How do budget caps and overage alerts work?

11. Observability and tamper-evident audit Describe your approach to structured logs, metrics, and distributed traces across control-plane services and runners. How do you produce an audit trail of security-relevant actions — secret access, approval decisions, permission changes — that cannot be quietly altered after the fact?

12. Reliability, recovery, and zero-downtime deployments How do you guarantee no push event is silently lost? How do you back up and restore the metadata database? How do you handle a full availability-zone or region outage? How do you roll out a database schema change or a new control-plane binary without dropping in-flight runs?

13. Key trade-offs and rollout strategy Discuss: shared runner pools vs. dedicated per-tenant pools; platform-managed runners vs. customer-hosted agents; and how you would phase the build of this system from a minimal first version to full production scale.


What a strong answer looks like

Cover every area above with enough detail to reveal genuine design decisions. Use rough numbers to justify component choices. Name trade-offs rather than presenting every decision as the obvious right answer. Code is not required.

Hints

Hint 1

Size the system before picking any components. Rough math — 2M runs/day at 5 jobs each, 8-minute average duration — puts peak concurrent jobs around 150k. That single number drives runner form factor, scheduler architecture, log pipeline throughput, and database write rates. Without it, every subsequent decision floats.

Hint 2

Idempotency is the central correctness challenge, not any individual component. Push events arrive at least once, runners crash mid-job, and retry logic fires from multiple code paths simultaneously. Every state transition should be a compare-and-set conditional write, and every message consumer should be able to re-process a message it already handled without changing the outcome. Design for this…

Hint 3

Fairness and isolation sound similar but require different mechanisms. Fairness is a scheduling policy question — whose job gets the next available runner slot. Isolation is a security and reliability question — preventing one tenant's workload from affecting another's correctness, performance, or data visibility. Answer them separately: fairness via weighted fair queuing across per-tenant ready q…