You can choose the amount of memory to provide for your Cloud Run worker pool. This page describes how to specify the amount of memory available for your worker pool.
Understand memory usage
Cloud Run instances that exceed their allowed memory limit are terminated.
The available memory for your instance needs to be sufficient for:
- Running the worker pool executable, because the executable must be loaded to memory
- Allocating memory in your worker pool process
- Writing files to the file system
The size of the deployed container image does not affect memory that is available for the instance.
Set and update memory limits
You can set memory limits on Cloud Run worker pools. By default, the memory allocated to each worker pool is 512 MiB.
Required minimum CPUs
The amount of allocated memory you choose corresponds to an amount of minimum CPU for your worker pool. When setting a memory limit, the following minimum CPU limits are required:
Memory | Minimum CPUs required |
---|---|
2 GiB | 1 vCPU |
More than 4 GiB | 2 vCPU |
More than 8 GiB | 4 vCPU |
More than 16 GiB | 6 vCPU |
More than 24 GiB | 8 vCPU |
Maximum amount of memory
The maximum amount of memory you can configure is
32 gibibyte (32 Gi
).
Minimum memory
The minimum memory setting is 512 MiB.
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 memory 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 memory limits for a Cloud Run worker pool using the Google Cloud CLI when you create a new worker pool or deploy a new revision:
gcloud
You can update the memory allocation of a given worker pool by using the following command:
gcloud beta run worker-pools update WORKER_POOL --memory SIZE
Replace:
- WORKER_POOL with the name of your worker pool
- SIZE with a memory size from the CPU and memory table.
The format for size is a fixed or floating point number followed
by a unit:
G
orM
corresponding to gigabyte or megabyte, respectively, or use the power-of-two equivalents:Gi
orMi
corresponding to gibibyte or mebibyte respectively.
You can also set memory limits during deployment using the command:
gcloud beta run worker-pools deploy --image IMAGE_URL --memory SIZE
Replace:
- IMAGE_URL with a reference to the container image that
contains the worker pool, such as
us-docker.pkg.dev/cloudrun/container/worker-pool:latest
. - SIZE with a memory size from the CPU and memory table. The format for size is a fixed or floating point number followed by a unit: G or M corresponding to gigabyte or megabyte, respectively, or use the power-of-two equivalents: Gi or Mi corresponding to gibibyte or mebibyte respectively.
View memory configuration for the worker pool
In the Google Cloud console, go to Cloud Run:
Click Worker pools to display the list of deployed worker pools.
Click the worker pool you want to examine to display its details pane.
Click the Containers tab to display worker pool memory configuration for each container.