The CI pipeline takes 45 minutes. Developers want it under 10. How do you approach it?
IntermediateScenarioPipelines at scale
Answer
Situation read → Don't optimise blindly. Measure where the time goes, then remove waiting, repetition and serial work.
What I'd do →
- Get timings per job and step for the last 50 runs; find the critical path.
- Cache dependencies and Docker layers (BuildKit cache to the registry or GitHub cache).
docker buildx build --cache-from type=registry,ref=ecr/app:cache \
--cache-to type=registry,ref=ecr/app:cache,mode=max -t ecr/app:$SHA --push .
- Parallelise: run lint, unit tests and the image build at the same time; shard tests across runners.
- Skip what's not affected: path filters, or build only changed services in a monorepo.
- Move slow end-to-end suites to after merge or to a nightly run, keeping a fast smoke test on PRs.
- Fix the slowest tests and remove sleeps; one 4-minute integration test is often half the problem.
Why → Time on the critical path is what developers feel; speeding up jobs off that path changes nothing.
Interview tip → Say "measure the critical path first"; it shows method rather than random tweaks.
More on Pipelines at scale
You have a monorepo with 40 services. Every commit builds and tests all of them. How do you fix that?AdvancedFlaky tests fail 1 in 5 runs and developers just click "re-run". How do you fix this culture and the tests?BeginnerYour self-hosted GitHub runners can't keep up at peak and sit idle at night. How do you run them at scale?AdvancedDocker builds in CI take 12 minutes because every runner starts with an empty cache. How do you speed them up?IntermediateHow do you secure the software supply chain from commit to production?AdvancedFifty teams have copy-pasted pipelines that have drifted apart. How do you standardise them?Intermediate