Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Use parallelism para especificar o número máximo de tarefas numa execução de trabalho que podem ser executadas em paralelo. Por predefinição, as tarefas são iniciadas o mais rapidamente possível, até um máximo que varia consoante o número de CPUs que estiver a usar.
A redução do paralelismo limita o número de tarefas executadas em paralelo. Isto é útil
nos casos em que um dos seus recursos de apoio, como uma base de dados, tem uma escalabilidade
limitada e não consegue processar um grande número de pedidos paralelos.
Funções necessárias
Para receber as autorizações de que
precisa para configurar tarefas do Cloud Run,
peça ao seu administrador para lhe conceder as
seguintes funções de IAM:
Selecione Tarefas no menu e clique em Implementar contentor para preencher a página de definições iniciais da tarefa. Se estiver a configurar uma tarefa existente,
selecione a tarefa e, de seguida, clique em Editar.
Clique em Recipientes, volumes, ligações, segurança para expandir a página de propriedades da tarefa.
Clique no separador Geral.
Selecione Executar o maior número possível de tarefas em simultâneo
para ter o melhor desempenho. Se precisar de diminuir o número de tarefas simultâneas, por exemplo, se os seus recursos de apoio forem limitados, selecione Limitar o número de tarefas simultâneas e, em seguida, especifique um número inteiro entre 0 e o número máximo de tarefas em execução em paralelo permitidas pela quota que não exceda o número de tarefas.
IMAGE_URL: uma referência à
imagem do contentor, por exemplo, us-docker.pkg.dev/cloudrun/container/job:latest.
PARALLELISM com um número inteiro entre 0 e o número máximo de tarefas em execução em paralelo, permitido pela quota, que não excede o número de tarefas.
Substituir PARALLELISM. Especifique um número inteiro entre 0 e o número máximo de tarefas em execução em paralelo permitido pela quota que não excede o número de tarefas.
Também pode especificar mais configurações, como variáveis de ambiente ou limites de memória.
resource"google_cloud_run_v2_job""default"{name="cloud-run-job-parallelism"location="us-central1"deletion_protection=false # set to "true" in productiontemplate{task_count=3parallelism=3template{containers{image="us-docker.pkg.dev/cloudrun/container/job:latest"}}}}
Veja as definições de paralelismo
Para ver as definições de paralelismo atuais para a sua tarefa do Cloud Run:
Consola
Na Google Cloud consola, aceda à página Tarefas do Cloud Run:
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-21 UTC."],[],[],null,["# Set parallelism for jobs\n\nYou use `parallelism` to specify the maximum number of tasks in a job execution\nthat can run in parallel. By default, tasks will be started as quickly as\npossible, up to a [maximum](/run/quotas) that varies depending on how many CPUs\nyou are using.\n\nLowering parallelism limits how many tasks run in parallel. This is useful\nin cases where one of your backing resources, such as a database, has limited\nscaling and cannot handle a large number of parallel requests.\n\nRequired roles\n--------------\n\n\nTo get the permissions that\nyou need to configure Cloud Run jobs,\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 job\n- [Service Account User](/iam/docs/roles-permissions/iam#iam.serviceAccountUser) (`roles/iam.serviceAccountUser`) on the service identity\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 job interfaces with\nGoogle Cloud APIs, such as Cloud Client Libraries, see the\n[service identity configuration guide](/run/docs/configuring/jobs/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 parallelism\n---------------------\n\nTo specify parallelism for a Cloud Run job: \n\n### Console\n\n\n1. In the Google Cloud console, go to the Cloud Run jobs page:\n\n [Go to Cloud Run](https://console.cloud.google.com/run)\n2. Select **Jobs** from the menu, and click **Deploy container** to fill out\n the initial job settings page. If you are configuring an existing job,\n select the job, then click **Edit**.\n\n3. Click **Container(s), Volumes, Connections, Security** to expand the job properties page.\n\n4. Click the **General** tab.\n\n - Select **Run as many tasks concurrently as possible** for best performance. If you need to lower the number of concurrent tasks, for example, if your backing resources are limited, select **Limit the number of concurrent tasks** and then specify an integer between 0 and the [maximum](/run/quotas) number of tasks running in parallel allowed by quota that don't exceed the number of tasks.\n5. Click **Create** or **Update**.\n\n### gcloud\n\n1. For a job you are creating:\n\n ```bash\n gcloud run jobs create JOB_NAME --image IMAGE_URL --parallelism PARALLELISM\n ```\n\n Replace\n - \u003cvar translate=\"no\"\u003eJOB_NAME\u003c/var\u003e with the name of your job.\n - \u003cvar translate=\"no\"\u003eIMAGE_URL\u003c/var\u003e: a reference to the [container image](/run/docs/building/containers)---for example, `us-docker.pkg.dev/cloudrun/container/job:latest`.\n - \u003cvar translate=\"no\"\u003ePARALLELISM\u003c/var\u003e with an integer between 0 and the [maximum](/run/quotas) number of tasks running in parallel, allowed by quota, that don't exceed the number of tasks.\n2. For a job you are updating:\n\n ```bash\n gcloud run jobs update JOB_NAME --parallelism PARALLELISM\n ```\n\n### YAML\n\n1. If you are creating a new job, skip this step.\n If you are updating an existing job, download its [YAML configuration](/run/docs/reference/yaml/v1#job):\n\n ```bash\n gcloud run jobs describe JOB_NAME --format export \u003e job.yaml\n ```\n2. Update the `parallelism:` attribute:\n\n ```yaml\n apiVersion: run.googleapis.com/v1\n kind: Job\n metadata:\n name: JOB_NAME\n spec:\n template:\n spec:\n parallelism: PARALLELISM\n template:\n spec:\n containers:\n - image: IMAGE\n ```\n\n Replace \u003cvar translate=\"no\"\u003ePARALLELISM\u003c/var\u003e. Specify an integer between 0 and the [maximum](/run/quotas) number of tasks running in parallel allowed by quota that\n don't exceed the number of tasks.\n\n You can also specify more configuration such as environment variables or\n memory limits.\n3. Update the existing job configuration:\n\n ```bash\n gcloud run jobs replace job.yaml\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).\nAdd the following to a [`google_cloud_run_v2_job`](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/cloud_run_v2_job) resource in your Terraform configuration: \n\n\u003cbr /\u003e\n\n resource \"google_cloud_run_v2_job\" \"default\" {\n name = \"cloud-run-job-parallelism\"\n location = \"us-central1\"\n\n deletion_protection = false # set to \"true\" in production\n\n template {\n task_count = 3\n parallelism = 3\n\n template {\n containers {\n image = \"us-docker.pkg.dev/cloudrun/container/job:latest\"\n }\n }\n }\n }\n\nView parallelism settings\n-------------------------\n\nTo view the current parallelism settings for your\nCloud Run job: \n\n### Console\n\n1. In the Google Cloud console, go to the Cloud Run jobs page:\n\n [Go to Cloud Run jobs](https://console.cloud.google.com/run/jobs)\n2. Click the job you are interested in to open the **Job details** page.\n\n3. Click **View and Edit job configuration**.\n\n4. Locate the parallelism setting in the configuration\n details.\n\n### gcloud\n\n1. Use the following command:\n\n ```bash\n gcloud run jobs describe JOB_NAME\n ```\n2. Locate the parallelism setting in the returned\n configuration."]]