Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Questa pagina mostra come scalare manualmente il pool di worker.
Panoramica
Lo scaling manuale ti consente di impostare un numero specifico di istanze senza richiedere il redeploy.
In questo modo, puoi scrivere la tua
logica di scalabilità utilizzando un sistema esterno. Per un esempio, consulta il gestore della scalabilità automatica di Kafka.
Considerazioni sulla fatturazione quando si utilizza la scalabilità manuale
Quando utilizzi la scalabilità manuale, tutte le istanze che hai richiesto vengono
fatturate come istanze attive, anche se sono inattive.
Per i dettagli completi della fatturazione, consulta la pagina dei prezzi.
Ruoli obbligatori
Per ottenere le autorizzazioni necessarie per eseguire il deployment dei pool di worker Cloud Run, chiedi all'amministratore di concederti i seguenti ruoli IAM:
Lettore Artifact Registry (roles/artifactregistry.reader)
sul repository Artifact Registry dell'immagine container di cui è stato eseguito il deployment (se applicabile)
Se stai configurando un nuovo worker pool, seleziona Worker pool dal menu e fai clic su Esegui il deployment del contenitore. Se stai
configurando un pool di lavoratori esistente, fai clic sul pool di lavoratori per visualizzare il relativo
riquadro dei dettagli, quindi fai clic sull'icona a forma di penna accanto a Scalabilità in alto a destra
del riquadro dei dettagli.
Individua il modulo Scalabilità (per un nuovo pool di worker) o il modulo
Modifica scalabilità per un pool di worker esistente.
Nel campo etichettato Numero di istanze, specifica il numero di istanze di container per il servizio.
Completa la specifica.
Fai clic su Crea per un nuovo pool di worker o su Salva per un pool di worker esistente.
gcloud
Per specificare lo scaling per un nuovo worker pool, utilizza il comando deploy:
INSTANCE_COUNT: il numero di istanze per il pool di worker.
In questo modo il pool di worker viene impostato sulla scalabilità manuale. Specifica un valore di 0 per disattivare
il pool di worker.
IMAGE_URL: un riferimento all'immagine container che
contiene il pool di worker, ad esempio us-docker.pkg.dev/cloudrun/container/worker-pool:latest.
Specifica la scalabilità per un pool di worker esistente utilizzando il seguente comando
update:
REGION: la regione Google Cloud , ad esempio
europe-west1.
IMAGE_URL: un riferimento all'immagine container che
contiene il pool di worker, ad esempio us-docker.pkg.dev/cloudrun/container/worker-pool:latest.
INSTANCE_COUNT: il numero di istanze per il pool di worker.
In questo modo il pool di worker viene impostato sulla scalabilità manuale. Specifica un valore di 0 per
disattivare il worker pool.
Visualizza la configurazione di scalabilità per un worker pool
[[["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."],[],[],null,["# Manual scaling for worker pools\n\n| **Preview\n| --- Cloud Run manual scaling**\n|\n|\n| This feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nThis page shows you how to manually scale your worker pool.\n\nOverview\n--------\n\nManual scaling lets you set a specific instance\ncount\nwithout requiring redeployment.\nThis gives you the option to write your own\nscaling logic using an external system. See the [Kafka Autoscaler](/run/docs/configuring/workerpools/kafka-autoscaler)\nfor an example of this.\n\nBilling considerations when using manual scaling\n------------------------------------------------\n\nWhen you use manual scaling, all the instances that you requested are\nbilled as *active* instances, even if they happen to be idle.\nFor complete billing details, see the [pricing page](/run/pricing).\n\nRequired roles\n--------------\n\n\nTo get the permissions that\nyou need to deploy Cloud Run worker pools,\n\nask your administrator to grant you the\nfollowing IAM roles:\n\n- [Cloud Run Developer](/iam/docs/roles-permissions/run#run.developer) (`roles/run.developer`) on the Cloud Run service\n- [Service Account User](/iam/docs/roles-permissions/iam#iam.serviceAccountUser) (`roles/iam.serviceAccountUser`) on the service identity\n- [Artifact Registry Reader](/iam/docs/roles-permissions/artifactregistry#artifactregistry.reader) (`roles/artifactregistry.reader`) on the Artifact Registry repository of the deployed container image (if applicable)\n\n\nFor a list of IAM roles and permissions that are associated with\nCloud Run, see\n[Cloud Run IAM roles](/run/docs/reference/iam/roles)\nand [Cloud Run IAM permissions](/run/docs/reference/iam/permissions).\nIf your Cloud Run worker pool interfaces with\nGoogle Cloud APIs, such as Cloud Client Libraries, see the\n[service identity configuration guide](/run/docs/configuring/workerpools/service-identity).\nFor more information about granting roles, see\n[deployment permissions](/run/docs/reference/iam/roles#additional-configuration)\nand [manage access](/iam/docs/granting-changing-revoking-access).\n\nConfigure scaling\n-----------------\n\nChanging scaling mode or changing the manual instance count\ndoes not create a new revision.\n\nTo configure the scaling mode, use the Google Cloud console or the Google Cloud CLI: \n\n### Console\n\n1. In the Google Cloud console, go to Cloud Run:\n\n [Go to Cloud Run](https://console.cloud.google.com/run/worker-pools)\n2. If you are configuring a new worker pool, select **Worker pools** from the menu, and\n click **Deploy container** . If you are\n configuring an existing worker pool, click the worker pool to display its\n detail pane, then click the pen icon next to **Scaling** at the top right\n of the detail panel.\n\n3. Locate the **Scaling** form (for a new worker pool) or the\n **Edit scaling** form for an existing worker pool.\n\n4. In the field labelled **Number of instances**, specify the number of container instances for the service.\n\n5. Finish the specification.\n\n6. Click **Create** for a new worker pool or **Save** for an existing worker pool.\n\n### gcloud\n\n\nTo specify scaling for a new worker pool, use the [deploy](/sdk/gcloud/reference/beta/run/worker-pools/deploy)\ncommand: \n\n```bash\ngcloud beta run worker-pools deploy WORKER_POOL \\\n --scaling=INSTANCE_COUNT \\\n --image IMAGE_URL\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eWORKER_POOL\u003c/var\u003e: the name of your worker pool.\n- \u003cvar translate=\"no\"\u003eINSTANCE_COUNT\u003c/var\u003e: the number of instances for the worker pool. This sets the worker pool to manual scaling. Specify a value of `0` to disable the worker pool.\n- \u003cvar translate=\"no\"\u003eIMAGE_URL\u003c/var\u003e: a reference to the container image that contains the worker pool, such as `us-docker.pkg.dev/cloudrun/container/worker-pool:latest`.\n\nSpecify scaling for an existing worker pool by using the following\n[update](/sdk/gcloud/reference/beta/run/worker-pools/update) command: \n\n```bash\ngcloud beta run worker-pools update WORKER_POOL \\\n --scaling=INSTANCE_COUNT\n```\n\n### Terraform\n\n\u003cbr /\u003e\n\nTo learn how to apply or remove a Terraform configuration, see\n[Basic Terraform commands](/docs/terraform/basic-commands).\n\n\u003cbr /\u003e\n\n resource \"google_cloud_run_v2_worker_pool\" \"default\" {\n name = \"\u003cvar translate=\"no\"\u003eWORKER_POOL\u003c/var\u003e\"\n location = \"\u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e\"\n launch_stage = \"BETA\"\n\n template {\n containers {\n image = \"\u003cvar translate=\"no\"\u003eIMAGE_URL\u003c/var\u003e\"\n }\n }\n scaling {\n scaling_mode = \"MANUAL\"\n manual_instance_count = \"\u003cvar translate=\"no\"\u003eINSTANCE_COUNT\u003c/var\u003e\"\n }\n }\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eWORKER_POOL\u003c/var\u003e: the name of the worker pool.\n- \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e: the Google Cloud region---for example, `europe-west1`.\n- \u003cvar translate=\"no\"\u003eIMAGE_URL\u003c/var\u003e: a reference to the container image that contains the worker pool, such as `us-docker.pkg.dev/cloudrun/container/worker-pool:latest`.\n- \u003cvar translate=\"no\"\u003eINSTANCE_COUNT\u003c/var\u003e: the number of instances for the worker pool. This sets the worker pool to manual scaling. Specify a value of `0` to disable the worker pool.\n\nView scaling configuration for a worker pool\n--------------------------------------------\n\n1. In the Google Cloud console, go to Cloud Run:\n\n [Go to Cloud Run](https://console.cloud.google.com/run/worker-pools)\n2. Click **Worker pools** to display the list of deployed worker pools.\n\n3. Click the worker pool you want to examine to display its details pane.\n\n4. The current scaling setting is shown above the worker pools revision list:\n **Scaling: Manual (Instances: )**.\n\n| **Note:** You can also use the Google Cloud CLI command [`gcloud beta run worker-pools describe`](/sdk/gcloud/reference/beta/run/worker-pools/describe) to view configuration details.\n\nDisable a worker pool\n---------------------\n\nTo disable a worker pool, use the following command to set scaling to zero: \n\n```bash\ngcloud beta run worker-pools update WORKER_POOL --scaling=0\n```\n\nReplace \u003cvar translate=\"no\"\u003eWORKER_POOL\u003c/var\u003e with the name of your worker pool."]]