This page describes how you can increase vCPU for your builds.
By default, Cloud Build runs your builds on a standard virtual machine (VM). In addition to the standard VM, Cloud Build provides several high-CPU VM types to run builds. To increase the speed of your build, select a machine with a higher vCPU to run builds. Keep in mind that although selecting a high vCPU machine increases your build speed, it may also increase the startup time of your build as Cloud Build only starts non-standard machines on demand.
If you require more vCPU options than the ones provided by default pools, you can choose to run your builds on private pools, which provides a number of high-CPU machine types for builds.
To learn more about the all the available machine types, see the Pricing page.
Before you begin
To use the command-line examples in this guide, install and configure the Google Cloud CLI.
- If you've installed gcloud CLI previously, make sure you have the
latest available version by running
gcloud components update
.
Increase vCPU for default pools
You can increase the vCPU for running builds in a default pool either by passing
the value directly to the gcloud builds submit
command or by specifying the
value in the build config file.
Pass the value directly to the gcloud builds submit
command:
To specify a custom VM size directly in the gcloud builds submit
command,
add the --machine-type
argument to the command:
gcloud builds submit --config=cloudbuild.yaml \
--machine-type=N1_HIGHCPU_8 .
Specify the value in the build config file:
YAML
Open your build config file.
Update the
machineType
field to an enum value corresponding to one of the supported machine types for default pools. The following example shows how to add themachineType
option to a build config file:steps: - name: 'gcr.io/cloud-builders/docker' args: ['build', '-t', 'gcr.io/my-project/image1', '.'] options: machineType: 'N1_HIGHCPU_8'
Start the build using the gcloud CLI or build triggers.
JSON
Open your build config file.
Update the
machineType
field to an enum value corresponding to one of the supported machine types for default pools. The following example shows how to add themachineType
option to a build config file:{ "steps": [ { "name": "gcr.io/cloud-builders/docker", "args": ["build", "-t", "gcr.io/my-project/image1", "."] }, "options": { "machineType": "N1_HIGHCPU_8" } }
Start the build using the gcloud CLI or build triggers.
Increase vCPU for private pools
Console
Open the Worker pool page in the Google Cloud console:
Select the project in which you created the private pool.
Click on the private pool name.
In the Edit private pool side panel, use the Machine type drop-down to select a larger machine type.
Click Save.
gcloud
You can increase the vCPU for running builds in a private pool either by passing
the value directly to the gcloud builds worker-pools update
command or by
specifying the value in the private pool config file.
Specify the value in the private pool config file:
Open your private pool config file.
Update the value of
machineType
field to one of the supported machine types .Run the following command, where
PRIVATEPOOL_ID
is the unique identifier for your private pool,REGION
is the region where your private pool is located, andPRIVATEPOOL_CONFIG_FILE
is the name of your private pool config file:gcloud builds worker-pools update PRIVATEPOOL_ID \ --region=REGION \ --config-from-file=PRIVATEPOOL_CONFIG_FILE
Pass the value directly to the gcloud builds worker-pools update
command:
gcloud builds worker-pools update PRIVATEPOOL_ID \
--region=REGION \
--worker-machine-type=PRIVATEPOOL_MACHINE_TYPE
Replace the placeholder values in the above commands with the following:
PRIVATEPOOL_ID
: the ID of your existing private pool. You cannot update this value; you must specify an existing private pool ID.REGION
: the region where you created your private pool.PRIVATEPOOL_DISK_SIZE
: the updated disk size.PRIVATEPOOL_MACHINE_TYPE
is the updated machine type.Cloud Build uses the updated machine type anytime you run builds using corresponding private pool.
What's next
- Learn about more best practices to speed up builds.