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 memory requirements for CPUs:
| CPUs | Memory required | 
|---|---|
| 1 vCPU | 128 MiB to 4 GiB | 
| 2 vCPU | 128 MiB to 8 GiB | 
| 4 vCPU | 2 to 16 GiB | 
| 6 vCPU | 4 to 24 GiB | 
| 8 vCPU | 4 to 32 GiB | 
Required roles
To get the permissions that you need to configure and deploy Cloud Run worker pools, ask your administrator to grant you the following IAM roles:
-  Cloud Run Developer 
( roles/run.developer) on the Cloud Run worker pool
-  Service Account User 
( roles/iam.serviceAccountUser) on the service identity
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 worker pool 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
Any configuration change leads to the creation of a new revision. Subsequent revisions will also automatically get this configuration setting unless you make explicit updates to change it.
You can set CPU limits for a Cloud Run worker pool using the Google Cloud console, the Google Cloud CLI, YAML, or Terraform:
Console
-  In the Google Cloud console, go to Cloud Run: 
-  Select Worker poolsfrom the menu, and click Deploy containerto configure a new worker pool. If you are configuring an existing worker pool, click the worker pool, then click Edit and deploy new revision. 
-  If you are configuring a new worker pool, fill out the initial worker pool page, then click Container(s), Volumes, Networking, Securityto expand the worker pools configuration page. 
-  Click the Containertab.  - Select the CPU limit from the CPU dropdown list.
 
-  Click Createor Deploy. 
gcloud
You can update the CPU limits for a given worker pool by using the following command:
gcloud beta run worker-pools update WORKER_POOL --cpu CPU
Replace
- WORKER_POOL with the name of your worker pool
-  CPU 
with the CPU limit. Specify the value 1,2,4,6, or8CPUs, following the requirements shown in the CPU and memory table.
You can also set CPU during deployment using the command:
gcloud beta run worker-pools deploy --image IMAGE_URL --cpu CPU
Replace
-  IMAGE_URL 
: a reference to the container image that
contains the worker pool, such as us-docker.pkg.dev/cloudrun/container/worker-pool:latest.
-  CPU 
with the value 1,2,4,6, or8CPUs, following the requirements shown in the CPU and memory table.
YAML
-  If you are creating a new worker pool, skip this step. If you are updating an existing worker pool, download its YAML configuration : gcloud beta run worker-pools describe WORKER_POOL --format export > workerpool.yaml 
-  The following example contains the YAML configuration: apiVersion : run.googleapis.com/v1 kind : WorkerPool metadata : name : WORKER_POOL annotations : run.googleapis.com/launch-stage : BETA spec : template : spec : containers : - image : IMAGE_URL resources : limits : cpu : ` CPU ` Replace the following: - WORKER_POOL : the name of your Cloud Run worker pool.
-  IMAGE_URL 
: a reference to the container image that
contains the worker pool, such as us-docker.pkg.dev/cloudrun/container/worker-pool:latest.
-  CPU 
: the CPU limit value.
Specify the value 1,2,4,6, or8CPUs, or for less than 1 CPU, specify a value from 0.08 to less than 1.00, in increments of 0.01. (See the table under Setting and updating CPU limits for required settings.)
 
-  Create or update the worker pool using the following command: gcloud beta run worker-pools replace workerpool.yaml 
Terraform
To learn how to apply or remove a Terraform configuration, see Basic Terraform commands .
  resource 
  
 "google_cloud_run_v2_worker_pool" 
  
 "default" 
  
 { 
  
 name 
  
 = 
  
 " WORKER_POOL 
" 
  
 location 
  
 = 
  
 " REGION 
" 
  
 launch_stage 
  
 = 
  
 "BETA" 
  
 template 
  
 { 
  
 containers 
  
 { 
  
 image 
  
 = 
  
 " IMAGE_URL 
" 
  
 resources 
  
 { 
  
 limits 
  
 = 
  
 { 
  
 cpu 
  
 = 
  
 " CPU 
" 
  
 } 
  
 } 
  
 } 
  
 } 
 } 
 
 
Replace:
- WORKER_POOL with the name of the worker pool.
- REGION with the Google Cloud region. For example, europe-west1.
-  IMAGE_URL 
: a reference to the container image that
contains the worker pool, such as us-docker.pkg.dev/cloudrun/container/worker-pool:latest
-  CPU 
with the value 1,2,4,6, or8CPUs, following the requirements shown in the CPU and memory table.
View CPU configuration for the worker pool
-  In the Google Cloud console, go to Cloud Run: 
-  Click Worker poolsto display the list of deployed worker pools. 
-  Click the worker pool you want to examine to display its details pane. 
-  Click the Containerstab to display CPU configuration for the worker pool. 

