Configure Cloud Run functions

When you deploy or update a function created with the Cloud Functions v2 API, you have access to all of Cloud Run's configuration capabilities. Use this page to understand a few of the configuration options that are available in Cloud Run, how to control the behavior of your functions, and what the best practices are for each type of configuration. See Cloud Run documentation for a full list of configuration options.

Guard against high request levels

You can control how many instances your function creates to serve requests. This can help to curb costs and guard against abnormally high request levels. See Set maximum instances to learn more.

Avoid cold starts and reduce latency

You can avoid cold starts for your application and reduce application latency by setting a minimum number of instances. Note that setting a minimum number of instances incurs cost. See Set minimum instances to learn more.

Secrets

You can use Secret Manager with your Cloud Run functions to securely store API keys, passwords, and other sensitive information. See Configure secrets to learn more.

Environment variables

You can create key/value pairs for use with your function. See Configure environment variables to learn more.

Capacity

You can control the amount of memory, CPU, and maximum concurrency a function can use.

Timeouts

You can set a Cloud Run request timeout that specifies the time within which a response must be returned. Alternatively, for functions created with the Cloud Functions v2 API, you can configure a function's timeout duration.

Recommendations

See Session affinity and traffic splitting to learn the optimizations provided by Recommender on Cloud Run.

Traffic splitting

Each time you deploy or redeploy a function, a new revision of the underlying Cloud Run service is automatically created. See Session affinity and traffic splitting for more details.