You use parallelism
to specify the maximum number of tasks that can run in
parallel. By default, tasks will be started as quickly as possible, up to a
maximum that varies depending on how many CPUs you are using:
CPUs | Maximum parallelism |
---|---|
1 | 100 |
2 | 50 |
4 | 25 |
More than 4 | 10 |
You can set parallelism to a lower value, up to the numbers shown in the table above. Lowering parallelism limits how many tasks run in parallel. This is useful in cases where one of your backing resources, such as a database, has limited scaling and cannot handle a large number of parallel requests.
To specify parallelism for a Cloud Run job:
Console
If you are configuring a new job, click the Jobs tab and fill out the initial job settings page as desired. If you are configuring an existing job, click the job, then click Edit.
Click Container, Variables, Connections, Security to expand the job properties page.
Click the General tab.
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 100 in the textbox.
Click Create or Update.
Command line
For a job you are creating:
gcloud beta run jobs create JOB_NAME --image IMAGE_URL --parallelism PARALLELISM
Replace
- JOB_NAME with the name of your job.
- IMAGE_URL with a reference to the container image, for
example,
us-docker.pkg.dev/cloudrun/container/job:latest
. - PARALLELISM Specify an integer between 0 and 100.
For a job you are updating:
gcloud beta run jobs update JOB_NAME --parallelism PARALLELISM
View parallelism settings
To view the current parallelism settings for your Cloud Run job:
Console
Click the job you are interested in to open the Job details page.
Click the Configuration tab.
Locate the parallelism setting in the configuration details.
Command line
Use the following command:
gcloud beta run jobs describe JOB_NAME
Locate the parallelism setting in the returned configuration.