Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Questa pagina descrive come aumentare le vCPU per le build.
Per impostazione predefinita, Cloud Build esegue le build su una macchina virtuale (VM) standard.
Oltre alla VM standard, Cloud Build fornisce
diversi tipi di VM con CPU elevata
per eseguire le build. Per aumentare la velocità della build, seleziona una macchina con un numero maggiore di vCPU per eseguirla. Tieni presente che, anche se la selezione di una macchina con un numero elevato di vCPU aumenta la velocità di compilazione, potrebbe anche aumentare il tempo di avvio della compilazione poiché Cloud Build avvia le macchine non standard solo su richiesta.
Se hai bisogno di più opzioni di vCPU rispetto a quelle fornite dai pool predefiniti,
puoi scegliere di eseguire le build su pool privati,
che forniscono una serie di tipi di macchine con CPU elevata per le build.
Per scoprire di più su tutti i tipi di macchine disponibili, consulta la pagina dei prezzi.
Prima di iniziare
Per utilizzare gli esempi di riga di comando in questa guida, installa e configura Google Cloud CLI.
Se hai già installato gcloud CLI, assicurati di avere la
versione più recente disponibile eseguendo gcloud components update.
Aumentare le vCPU per i pool predefiniti
Puoi aumentare le vCPU per l'esecuzione delle build in un pool predefinito passando il valore direttamente al comando gcloud builds submit o specificandolo nel file di configurazione della build.
Passa il valore direttamente al comando gcloud builds submit:
Per specificare una dimensione VM personalizzata direttamente nel comando gcloud builds submit,
aggiungi l'argomento --machine-type al comando:
Seleziona il progetto in cui hai creato il pool privato.
Fai clic sul nome del pool privato.
Nel riquadro laterale Modifica pool privato, utilizza il menu a discesa Tipo di macchina per selezionare un tipo di macchina più grande.
Fai clic su Salva.
gcloud
Puoi aumentare le vCPU per l'esecuzione delle build in un pool privato passando il valore direttamente al comando gcloud builds worker-pools update o specificandolo nel file di configurazione del pool privato.
Specifica il valore nel file di configurazione del pool privato:
Aggiorna il valore del campo machineType con uno dei tipi di macchine supportati .
Esegui il seguente comando, dove PRIVATEPOOL_ID è
l'identificatore univoco del pool privato, REGION
è la regione in cui si trova il pool privato e PRIVATEPOOL_CONFIG_FILE
è il nome del file di configurazione del pool privato:
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eCloud Build allows you to increase the vCPU for your builds to enhance build speed by selecting a high-CPU virtual machine (VM).\u003c/p\u003e\n"],["\u003cp\u003eYou can increase vCPU for builds in default pools by using the \u003ccode\u003egcloud builds submit\u003c/code\u003e command with the \u003ccode\u003e--machine-type\u003c/code\u003e argument or by specifying the \u003ccode\u003emachineType\u003c/code\u003e field in the build config file.\u003c/p\u003e\n"],["\u003cp\u003eTo increase vCPU in private pools, you can use the \u003ccode\u003egcloud builds worker-pools update\u003c/code\u003e command or update the \u003ccode\u003emachineType\u003c/code\u003e field in the private pool config file.\u003c/p\u003e\n"],["\u003cp\u003eSelecting a high-vCPU machine can reduce build time, but may increase build startup time since non-standard machines are started on demand by Cloud Build.\u003c/p\u003e\n"],["\u003cp\u003eThe specific vCPU options available for both default and private pools can be found in the Cloud Build pricing page and the private pool configuration file schema, respectively.\u003c/p\u003e\n"]]],[],null,["# Increase vCPU for builds\n\nThis page describes how you can increase vCPU for your builds.\n\nBy default, Cloud Build runs your builds on a standard virtual machine (VM).\nIn addition to the standard VM, Cloud Build provides\n[several high-CPU VM types](/build/docs/api/reference/rest/v1/projects.builds#machinetype)\nto run builds. To increase the speed of your build, select a machine\nwith a higher vCPU to run builds. Keep in mind that although selecting a high vCPU machine\nincreases your build speed, it may also increase the startup time of your build as\nCloud Build only starts non-standard machines on demand.\n\nIf you require more vCPU options than the ones provided by default pools,\nyou can choose to run your builds on [private pools](/build/docs/private-pools/private-pools-overview),\nwhich provides a number of high-CPU machine types for builds.\n\nTo learn more about the all the available machine types, see the [Pricing page](/build/pricing).\n\nBefore you begin\n----------------\n\nTo use the command-line examples in this guide, install and configure the\n[Google Cloud CLI](/sdk/docs/install-sdk).\n\n- If you've installed gcloud CLI previously, make sure you have the latest available version by running `gcloud components update`.\n\nIncrease vCPU for default pools\n-------------------------------\n\nYou can increase the vCPU for running builds in a default pool either by passing\nthe value directly to the `gcloud builds submit` command or by specifying the\nvalue in the build config file.\n\n**Pass the value directly to the `gcloud builds submit` command:**\n\nTo specify a custom VM size directly in the `gcloud builds submit` command,\nadd the `--machine-type` argument to the command: \n\n gcloud builds submit --config=cloudbuild.yaml \\\n --machine-type=E2_HIGHCPU_8\n\n**Specify the value in the build config file:** \n\n### YAML\n\n1. Open your [build config file](/build/docs/build-config-file-schema).\n\n2. Update the [`machineType`](/build/docs/api/reference/rest/v1/projects.builds#machinetype)\n field to an enum value corresponding to one of the [supported machine types for default pools](/build/pricing).\n The following example shows how to add the `machineType` option to a\n build config file:\n\n steps:\n - name: 'gcr.io/cloud-builders/docker'\n args: ['build', '-t', 'gcr.io/my-project/image1', '.']\n options:\n machineType: 'E2_HIGHCPU_8'\n\n3. Start the build using the [gcloud CLI](/build/docs/running-builds/start-build-manually)\n or [build triggers](/build/docs/automating-builds/create-manage-triggers).\n\n### JSON\n\n1. Open your [build config file](/build/docs/build-config-file-schema).\n\n2. Update the [`machineType`](/build/docs/api/reference/rest/v1/projects.builds#machinetype)\n field to an enum value corresponding to one of the [supported machine types for default pools](/build/pricing).\n The following example shows how to add the `machineType` option to a\n build config file:\n\n {\n \"steps\": [\n {\n \"name\": \"gcr.io/cloud-builders/docker\",\n \"args\": [\"build\", \"-t\", \"gcr.io/my-project/image1\", \".\"]\n },\n \"options\": {\n \"machineType\": \"E2_HIGHCPU_8\"\n }\n }\n\n3. Start the build using the [gcloud CLI](/build/docs/running-builds/start-build-manually)\n or [build triggers](/build/docs/automating-builds/create-manage-triggers).\n\nIncrease vCPU for private pools\n-------------------------------\n\n### Console\n\n1. Open the **Worker pool** page in the Google Cloud console:\n\n [Open the Cloud Build worker pool page](https://console.cloud.google.com/cloud-build/settings/worker-pool)\n2. Select the project in which you created the private pool.\n\n3. Click on the private pool name.\n\n4. In the **Edit private pool** side panel, use the **Machine type** drop-down\n to select a larger machine type.\n\n5. Click **Save**.\n\n### gcloud\n\nYou can increase the vCPU for running builds in a private pool either by passing\nthe value directly to the `gcloud builds worker-pools update` command or by\nspecifying the value in the private pool config file.\n\n**Specify the value in the private pool config file:**\n\n1. Open your [private pool config\n file](/build/docs/private-pools/worker-pool-config-file-schema).\n\n2. Update the value of `machineType` field to one of the supported\n [machine types](/build/docs/private-pools/private-pool-config-file-schema#machinetype) .\n\n3. Run the following command, where \u003cvar translate=\"no\"\u003ePRIVATEPOOL_ID\u003c/var\u003e is\n the unique identifier for your private pool, \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e\n is the region where your private pool is located, and \u003cvar translate=\"no\"\u003ePRIVATEPOOL_CONFIG_FILE\u003c/var\u003e\n is the name of your private pool config file:\n\n gcloud builds worker-pools update \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003ePRIVATEPOOL_ID\u003c/span\u003e\u003c/var\u003e \\\n --region=\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eREGION\u003c/span\u003e\u003c/var\u003e \\\n --config-from-file=\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003ePRIVATEPOOL_CONFIG_FILE\u003c/span\u003e\u003c/var\u003e\n\n**Pass the value directly to the `gcloud builds worker-pools update` command:** \n\n gcloud builds worker-pools update \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-nx\"\u003ePRIVATEPOOL_ID\u003c/span\u003e\u003c/var\u003e \\\n --region=\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-nx\"\u003eREGION\u003c/span\u003e\u003c/var\u003e \\\n --worker-machine-type=\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-nx\"\u003ePRIVATEPOOL_MACHINE_TYPE\u003c/span\u003e\u003c/var\u003e\n\nReplace the placeholder values in the above commands with the following:\n\n- \u003cvar translate=\"no\"\u003ePRIVATEPOOL_ID\u003c/var\u003e: the ID of your existing private pool. You cannot update this value; you must specify an existing private pool ID.\n- \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e: the [region](/build/docs/locations) where you created your private pool.\n- \u003cvar translate=\"no\"\u003ePRIVATEPOOL_DISK_SIZE\u003c/var\u003e: the updated disk size.\n- \u003cvar translate=\"no\"\u003ePRIVATEPOOL_MACHINE_TYPE\u003c/var\u003e is the updated machine type.\n\n Cloud Build uses the updated machine type anytime you run builds\n using corresponding private pool.\n\nWhat's next\n-----------\n\n- Learn about more best practices to [speed up builds](/build/docs/optimize-builds/speeding-up-builds)."]]