Índice do artigofaltam 4 min de leitura
Before you "buy a bigger machine": find out where the bottleneck is
Three things make CI slow (and almost nobody measures them):
- Queue: the job is waiting for an available runner.
- Download: dependencies and images are downloaded over and over.
- CPU/IO: build and tests actually consuming resources.
The order matters because, if the problem is the queue, optimizing the build alone will not fix it.
Where to read each signal
Each of the three has its own place to measure. Look at at least one week of jobs before deciding.
- Queue: while the job is
pending, it is waiting for a free runner. The GitLab jobs API returns, for each job, the fieldqueued_duration(time in queue, in seconds) next toduration(execution time). Compare the two: if the queue adds up to minutes and execution to seconds, the bottleneck is runner capacity, not code. - Download: the job log also records what happens before and after the script, such as preparing the executor, pulling the image, restoring the cache and downloading artifacts. Since GitLab 18.9, per-line log timestamps are generally available, and the documentation itself recommends them for finding bottlenecks and measuring how long each step takes. With them, you just subtract the time of one stage from the next. If pulling the image and restoring dependencies takes longer than the script, the gains come from caching and from having a registry close to the runner.
- CPU/IO: what is left is the script itself. Here the signal is on the runner host: watch CPU, memory and disk while jobs run (with
docker statson the Docker executor, or with the monitoring you already use on the machine). CPU or disk maxed out during tests means resources are short or too many jobs run in parallel.
To mark sections of your own script in the log, GitLab accepts collapsible sections with section_start and section_end markers, each with the Unix timestamp. This helps separate, for example, dependency installation from test execution.
1. Concurrency: concurrent and limit (what changes in practice)
In GitLab Runner, the config.toml file controls how many jobs a runner can process at the same time.
Example configuration:
concurrent = 4
[[runners]]
name = "dedicated-runner"
limit = 2concurrent(global) limits how many jobs in total can run at the same time, adding up all runners registered in thatconfig.toml. The value0is not accepted.limit(per runner) limits how many jobs that specific runner accepts in parallel. The default0means no limit.request_concurrency(per runner) defines how many requests for new jobs the runner makes to GitLab at the same time. The default is1, and the GitLab documentation points to this value as a cause of delay on high-volume runners. If the queue grows while the runner sits idle, it is worth testing a higher value.
Adjust with care:
- if you increase concurrency without increasing CPU/RAM, you "just split the pain"
- for front-end, 2 to 4 stable jobs are usually better than 8 jobs fighting over memory
2. Cache and artifacts: cheap speed-up (and highly underrated)
Cache (dependencies and intermediate build)
Use cache for:
node_modules(when it makes sense)- the
pnpm store/.yarn/cachefolder - bundler cache (e.g.
.vite,.next/cache)
Simple idea: download once, reuse many times.
Artifacts (job outputs)
Artifacts are good for:
- front-end builds (the output of
dist/) - reports (coverage, tests)
- packages to be deployed
Careful: large artifacts slow the pipeline down in another way (upload/download).
3. Runner tags: matching each job to the machine it needs
Separating runners by tags solves two problems:
- critical jobs do not get stuck behind long jobs
- you avoid running an "expensive" job on a "cheap" machine
Practical suggestion:
runner:fast→ lint/typecheck/unitrunner:e2e→ Cypress/Playwrightrunner:macos→ iOS/macOSrunner:windows→ Windows-only
4. Docker executor: performance + isolation (with a warning)
The Docker executor is a great choice because each job runs in a container and the environment is reproducible.
A direct speed gain is the if-not-present pull policy: the runner only downloads the image when there is no local copy. The GitLab documentation adds two caveats: do not use this policy on a runner shared by users who may have access to private images, and remember that the local copy does not update itself, so you need to delete the image from time to time to force the new version (and it does not work if the job must always run on the latest image). Another option the GitLab documentation recommends is using the Dependency Proxy or a Docker Hub mirror to shorten image downloads.
The warning is security: depending on the configuration, you may expose yourself to unnecessary risks. The GitLab documentation warns that privileged mode turns off the container's security mechanisms and can allow a job to escape to the host. Treat "isolation" as a requirement, especially if the runner will be shared across projects.
5. Quick checklist of "easy wins" (30 to 60 min)
- enable cache (dependencies + bundler)
- reduce downloads (pin base images, registry close to the runner)
- split the pipeline into smaller, parallelizable jobs
- limit concurrency to keep things stable
- put the runner on an SSD and a wired network
- separate tags (E2E should not compete with lint)
Useful references
- Advanced configuration (
concurrent,limit,request_concurrency): https://docs.gitlab.com/runner/configuration/advanced-configuration/ - Docker executor: https://docs.gitlab.com/runner/executors/docker/
- Job logs (timestamps and sections): https://docs.gitlab.com/ci/jobs/job_logs/
- Jobs API (
queued_duration): https://docs.gitlab.com/api/jobs/ - Speed up job execution (image proxy and mirror): https://docs.gitlab.com/runner/configuration/speed_up_job_execution/





