DevOps / Github Interview questions
How do you optimize GitHub Actions workflow performance for a large monorepo?
In a monorepo, the biggest performance killer is running every job for every change, even when a commit only touched one small service out of dozens. Optimization mostly comes down to running less, running it in parallel, and reusing what's already built.
- Path filters - only trigger a service's jobs when files under its path actually changed, using
on: push: paths: ['services/api/**'], instead of running the whole workflow on every commit. - Matrix builds - use a
strategy: matrixto run the same job across multiple services or test shards in parallel runner instances, instead of looping through them sequentially in one job. - Job-level parallelism with needs - let independent jobs run concurrently and only serialize the ones that genuinely depend on each other's output.
- Aggressive, well-scoped caching - cache dependency directories per-service with keys tied to that service's own lockfile, so unrelated services don't invalidate each other's cache.
- Reusable workflows - factor shared setup steps into a reusable workflow called via
uses, avoiding duplicated YAML that's slow to maintain and easy to let drift out of sync.
The combination that tends to matter most in practice is path filters plus matrix builds: together they stop unrelated services from being rebuilt and split what does need to run into parallel runner instances instead of one long sequential job.
More Related questions...