Configure CPU limits for jobs

This page describes how to specify the number of CPUs to use for each Cloud Run instance. By default, Cloud Run container instances are limited to 1 CPU. You can increase or decrease this value as described in this page.

Set and update CPU limits

By default, each instance is limited to 1 CPU. You can change this to any of the values shown in the following table.

CPU and memory table

The following are minimum memory requirements for CPUs:

CPUs Minimum memory
1 512 MiB
2 512 MiB
4 2 GiB
6 4 GiB
8 4 GiB

Required roles

To get the permissions that you need to configure Cloud Run jobs, ask your administrator to grant you the following IAM roles:

For a list of IAM roles and permissions that are associated with Cloud Run, see Cloud Run IAM roles and Cloud Run IAM permissions . If your Cloud Run job interfaces with Google Cloud APIs, such as Cloud Client Libraries, see the service identity configuration guide . For more information about granting roles, see deployment permissions and manage access .

Configure CPU limits

You must set a minimum of 1 CPU for a Cloud Run job.

To specify CPU for a Cloud Run job:

Console

  1. In the Google Cloud console, go to the Cloud Run jobs page:

    Go to Cloud Run

  2. Select Jobsfrom the menu, and click Deploy containerto fill out the initial job settings page. If you are configuring an existing job, select the job, then click Edit.

  3. Click Container(s), Volumes, Connections, Securityto expand the job properties page.

  4. Click the Generaltab.

    image

    • Select the desired CPU limit from the dropdown list. Select a value of 1 , 2 , 4 , 6 , or 8 CPUs. Jobs require a minimum of 1 CPU. (See the table under Setting and updating CPU limits for required settings.)
  5. Click Createor Update.

gcloud

  1. Update the CPU limits of a given job by using the following command:

    gcloud  
    run  
     jobs 
      
    update  
     JOB_NAME 
      
    --cpu  
     CPU 
    

    Replace

    • JOB_NAME with the name of your job
    • CPU with the desired CPU limit. Specify the value 1 , 2 , 4 , 6 , or 8 CPUs. Jobs require a minimum of 1 CPU. (See the table under Setting and updating CPU limits for required settings.)

    You can also set CPU when you create a job using the command:

    gcloud  
    run  
     jobs 
      
    create  
     JOB_NAME 
      
    --image  
     IMAGE_URL 
      
    --cpu  
     CPU 
    

    Replace

    • JOB_NAME with the name of your job.
    • IMAGE_URL : a reference to the container image —for example, us-docker.pkg.dev/cloudrun/container/job:latest .
    • CPU with the desired CPU limit. Specify the value 1 , 2 , 4 , 6 , or 8 CPUs. Jobs require a minimum of 1 CPU. (See the table under Setting and updating CPU limits for required settings.)

YAML

  1. If you are creating a new job, skip this step. If you are updating an existing job, download its YAML configuration :

    gcloud  
    run  
     jobs 
      
    describe  
     JOB_NAME 
      
    --format  
     export 
      
    >  
    job.yaml
  2. Update the cpu attribute:

     apiVersion 
     : 
      
     run.googleapis.com/v1 
     kind 
     : 
      
     Job 
     metadata 
     : 
      
     name 
     : 
      
      JOB 
     
     spec 
     : 
      
     template 
     : 
      
     spec 
     : 
      
     template 
     : 
      
     spec 
     : 
      
     containers 
     : 
      
     - 
      
     image 
     : 
      
      IMAGE 
     
      
     resources 
     : 
      
     limits 
     : 
      
     cpu 
     : 
      
      CPU 
      
     
    

    Replace CPU with the desired CPU limit. Specify the value 1 , 2 , 4 , 6 , or 8 CPUs. Jobs require a minimum of 1 CPU. (See the table under Setting and updating CPU limits for required settings.)

    You can also specify more configuration such as environment variables or memory limits.

  3. Update the existing job configuration:

    gcloud  
    run  
     jobs 
      
    replace  
    job.yaml

Terraform

To learn how to apply or remove a Terraform configuration, see Basic Terraform commands .

Add the following to a google_cloud_run_v2_job resource in your Terraform configuration:
   
 resource 
  
 "google_cloud_run_v2_job" 
  
 "default" 
  
 { 
  
 name 
  
 = 
  
 "cloudrun-job" 
  
 location 
  
 = 
  
 " REGION 
" 
  
 deletion_protection 
  
 = 
  
 false 
  
 template 
  
 { 
  
 template 
  
 { 
  
 containers 
  
 { 
  
 image 
  
 = 
  
 "us-docker.pkg.dev/cloudrun/container/job" 
  
 resources 
  
 { 
  
 limits 
  
 = 
  
 { 
  
 cpu 
  
 = 
  
 " CPU 
" 
  
 } 
  
 } 
  
 } 
  
 } 
  
 } 
  
 } 
 

Replace:

  • REGION with the Google Cloud region. For example, europe-west1 .
  • CPU with your service's required memory limit. Specify the value 1 , 2 , 4 , 6 , or 8 CPUs. Jobs require a minimum of 1 CPU. (See the table under Setting and updating CPU limits for required settings.)

View CPU settings

To view the current CPU settings for your Cloud Run job:

Console

  1. In the Google Cloud console, go to the Cloud Run jobs page:

    Go to Cloud Run jobs

  2. Click the job you are interested in to open the Job detailspage.

  3. Click View and Edit job configuration.

  4. Locate the CPU setting in the configuration details.

gcloud

  1. Use the following command:

    gcloud  
    run  
     jobs 
      
    describe  
     JOB_NAME 
    
  2. Locate the CPU setting in the returned configuration.

Design a Mobile Site
View Site in Mobile | Classic
Share by: