Course contentsShow
← Cloud and Infrastructure
Lesson 1764 of 2,98936. GitLab CI/CDFree lesson

GitLab Runner Auto-Scaling

Configure GitLab Runner with Docker Machine or Kubernetes executor for dynamic auto-scaling of build capacity.

GitLab Runner Auto-Scaling

You'll learn how to configure GitLab Runners to dynamically scale build capacity up and down based on pipeline demand.

What Is Runner Auto-Scaling?

Imagine a restaurant that magically adds or removes kitchen staff based on how many customers walk in. GitLab Runner auto-scaling works similarly—it automatically spins up additional build machines when your pipeline queue grows, then terminates them when they're idle. This keeps your builds fast during peak times without wasting resources (and money) when things are quiet.

Auto-scaling is particularly valuable for teams with bursty CI/CD workloads: lots of activity during business hours, quiet at night, or sudden spikes when multiple developers push changes simultaneously.

Two Primary Auto-Scaling Approaches

Docker Machine Executor

Docker Machine (though deprecated, still widely used) provisions virtual machines on demand from cloud providers (AWS, GCP, Azure). Each VM runs Docker and executes jobs. You configure autoscaling parameters in the runner's config.toml:

  • IdleCount: Minimum idle machines to keep warm
  • IdleTime: How long before idle machines terminate
  • MaxBuilds: Jobs per machine before recycling

The runner monitors the job queue and automatically creates/destroys VMs based on these thresholds.

Kubernetes Executor

For modern infrastructure, the Kubernetes executor is preferred. GitLab Runner runs as a pod in your cluster and spawns additional pods for each job. Kubernetes' native scheduling handles resource allocation, and you can leverage cluster autoscaling for the underlying nodes. Configure resource requests/limits to optimize pod placement.

Configuration Snapshot

Both approaches require runner registration with appropriate executor settings, cloud credentials, and scaling parameters that balance responsiveness (how quickly new capacity appears) against cost (avoiding over-provisioning).

Key Takeaway: GitLab Runner auto-scaling dynamically adjusts build capacity using Docker Machine (VM-based) or Kubernetes (container-based) executors, ensuring fast builds during high demand while minimizing idle resource costs.