An engineering organisation hosts 2,000 repositories and wants its own continuous integration service. Every push or pull request triggers a pipeline of jobs (compile, unit tests, lint, package) defined in a file in the repository. Developers push about 40,000 times a day, mostly in office hours, creating up to 3,000 jobs waiting at peak. Jobs run from 1 minute to 1 hour in isolated containers. Developers watch logs live in the browser, download build artefacts, and see a pass or fail status on their pull request. The web UI, webhooks and log viewers generate about 2,000 API requests per second at peak.
Functional requirements
Trigger pipelines from repository webhooks (push and pull request)
Queue jobs and run them on isolated build workers
Stream job logs live to the browser and keep them for 90 days
Store build artefacts and caches for later jobs and downloads
Report job status back to the code host and allow cancel and retry
Non-functional requirements
A job starts within 60 seconds of being queued during normal load
No accepted webhook is lost; each job runs at least once and its result is recorded once
Worker capacity scales up for office hours and down overnight to save cost
One repository's jobs cannot read another's secrets or artefacts
Constraints and scale
2,000 repositories and 40,000 pushes per day
Up to 3,000 concurrent queued or running jobs at peak
About 2,000 API requests per second from webhooks, UI and log viewers
You will practise
Decouple job submission from execution with a durable job queue
Autoscale a worker pool and handle workers that disappear mid-job
Store large logs and artefacts cheaply and stream logs live
Show 3 hints
A worker dies 20 minutes into a job. How does the system notice and rerun it?
Log lines arrive continuously. Where do they live while the job runs, and where afterwards?
What signal should drive scaling the worker pool up and down?