Configuring Memory Limits

Cloud Run locations

Cloud Run is regional, which means the infrastructure that runs your Cloud Run services is located in a specific region and is managed by Google to be redundantly available across all the zones within that region.

Meeting your latency, availability, or durability requirements are primary factors for selecting the region where your Cloud Run services are run. You can generally select the region nearest to your users but you should consider the location of the other GCP products that are used by your Cloud Run service. Using GCP products together across multiple locations can affect your service's latency as well as cost.

Cloud Run is available in the following regions:
  • us-central1 (Iowa)
If you already created a Cloud Run service, you can view the region in the Cloud Run dashboard in the GCP Console.

This page describes how to set memory limits.

Understanding memory usage

Cloud Run applications that exceed their allowed memory limit are terminated.

When you configure memory limit settings, the memory allocation you are specifying is used for:

  • Operating your service
  • Writing files to disk
  • Running binaries or other processes in your container, such as the nginx web server.

Setting and updating memory limits

By default, the memory allocated to each container instance of a revision is 256MiB.

Like any configuration change, setting an memory limits leads to the creation of a new revision. Subsequent revisions will also automatically get this memory limit unless you make explicit updates to change it.

You can set memory limits using the GCP Console or the gcloud command line when you create a new service or deploy a new revision:


  1. Go to Cloud Run

  2. Click CREATE SERVICE if you are setting memory limits on a new service you are deploying to. If you are setting limits on an existing service, then click on the service, then click DEPLOY NEW REVISION.



  4. Select the desired memory size from the dropdown list.

  5. Click Create or Deploy.

Command line

You can update the memory allocation of a given service by using the following command:

gcloud beta run services update [SERVICE] --memory [SIZE]

Replace [SERVICE] with the name of your service and [SIZE] with the desired memory size. The format for size is a fixed or floating point number followed by a unit: G, M, or K corresponding to gigabyte, megabyte, or kilobyte, respectively, or use the power-of-two equivalents: Gi, Mi, Ki corresponding to gibibyte, mebibyte or kibibyte respectively.

  • When deploying to Cloud Run, the maximum amount of memory is 2 gibibyte (2iG) and the number you specify is rounded up to the nearest 128MiB.

  • When deploying to Cloud Run on GKE, the maximum aount of memory is limited by the configuration of your GKE cluster.

You can also set memory limits during deployment using the command:

gcloud beta run deploy --image[PROJECT-ID]/[IMAGE] --memory [SIZE]


  • [PROJECT-ID] with your GCP project ID.
  • [IMAGE] with the name of your image.
  • [SIZE] with the values described above.

Optimizing memory

The peak memory requirement for a service can be found using the following: (Standing Memory) + (Memory per Request) * (Service Concurrency)


  • If you raise the concurrency of your service, you should also increase the memory limit to account for peak usage.

  • If you lower the concurrency of your service, consider reducing the memory limit to save on memory usage costs.

For more guidance on minimizing per request memory usage read Development Tips on Global Variables.

Was this page helpful? Let us know how we did:

Send feedback about...