Configure memory and vCPU limits (1st gen)
You can provision Cloud Run functions with different amounts of memory to control the limit on how much memory a function can use. The amount of allocated memory you choose corresponds to an amount of allocated CPU for your function. Available memory and CPU tiers are shown in the following table:
Memory | CPU |
---|---|
128MB | .083 vCPU |
256MB | .167 vCPU |
512MB | .333 vCPU |
1024MB | .583 vCPU |
2048MB | 1 vCPU |
4096MB | 2 vCPU |
8192MB | 2 vCPU |
Not available | 4 vCPU |
Not available | 8 vCPU |
By default, the memory allocated for a function is 256MB or 256 MiB depending on the Cloud Run functions product version.
See Cloud Run functions Pricing for information about costs associated with memory and CPU allocations.
Set a memory limit
You can set a function's allocated memory at deployment using the Google Cloud CLI or the Google Cloud console:
gcloud
If you are deploying a function using the gcloud CLI, use the
--memory
flag:
gcloud functions deploy YOUR_FUNCTION_NAME --memory=MEMORY_LIMIT ...
Console
To set the allocated memory during function creation in the Google Cloud console:
- Go to the Cloud Run functions Overview page in the Google Cloud console.
- Click Create function.
- Fill in the required fields for your function.
- Expand the Runtime, build... section at the end of the page and click the Runtime tab.
- In the Memory allocated field, select an amount of memory.
- Click Next.
- Click Deploy.