This guide compares the latest and original Google Cloud choices for deploying functions. This page helps those who previously created functions with the Cloud Functions API and are transitioning to the Cloud Run Admin API. This page describes key differences in several areas, such as concepts, configuration, deployment, and triggers and retries.
Comparison
There are two versions of Cloud Run functions:
Cloud Run functions, formerly known as Cloud Functions (2nd gen), is the latest version of functions that you can deploy as a service on Cloud Run. The function can react to HTTP(S) requests or respond to events propagated by Eventarc-based triggers, such as Pub/Sub.
Cloud Run functions (1st gen), formerly known as Cloud Functions (1st gen), is the original version of functions with limited event triggers and configurability.
We recommend using the current version of Cloud Run functions because it gives you more flexibility and control over your function runtime. By deploying functions directly onto Cloud Run, your functions will will be automatically built as containers and deployed as a Cloud Run service.
Concepts
The following table summarizes the conceptual differences for functions.
Cloud Run functions | Cloud Run functions (1st gen) | |
---|---|---|
Former product name | Cloud Functions (2nd gen) | Cloud Functions (1st gen) |
Resource model | A function is a Cloud Run service that is deployed from source code | A function is deployed from source code |
Types of functions terminology |
|
|
Assigned HTTPS URL | run.app Functions created with the Cloud Functions API (v2) also have a cloudfunctions.net endpoint. |
cloudfunctions.net |
Image registry | Artifact Registry only | Artifact Registry or Container Registry (deprecated) |
IAM roles for deployment |
|
|
Internal infrastructure | Cloud Run | Google internal |
Pricing model | Cloud Run pricing | Cloud Run functions (1st gen) pricing |
Configuration
Cloud Run builds functions into containers and deploys them as services. When you deploy a function to Cloud Run, you have complete access and control over the function's behavior. For example, you can enable Direct VPC, configure GPUs, use volume mounts, and more.
The following table summarizes the configuration differences for functions:
Cloud Run functions | Cloud Run functions (1st gen) | |
---|---|---|
Request timeout |
|
|
Instance size | Up to 16 GiB RAM with 4 vCPU | Up to 8 GB RAM with 2 vCPU |
Concurrency | Up to 1000 concurrent requests per function instance | 1 concurrent request per function instance |
Traffic splitting | Supported | Not supported |
Deployment
Since August 2024, you can use Cloud Run to deploy and manage functions created with the Cloud Functions API (v2). As a result of this change:
- Function metadata such as runtime ID and build configurations are stored in the Cloud Run service definition.
- You can safely edit your function using the Cloud Run Admin API.
- You can rely on the Cloud Run service definition as the source of truth for your function.
However, note that functions created with the Cloud Run Admin API cannot be modified with the Cloud Functions API.
The following table summarizes the differences in how you create, deploy, edit, and manage functions:
Cloud Run functions | Cloud Run functions (1st gen) | |
---|---|---|
Google Cloud console | Cloud Run | Cloud Run functions (1st gen) |
Cloud SDK |
|
|
REST API |
|
|
Terraform |
|
Triggers and retries
The following table compares triggers and retries for functions:
Cloud Run functions | Cloud Run functions (1st gen) | |
---|---|---|
Trigger and invoke a function | For function created with the Cloud Run Admin API, you
specify triggers as part of deploying the function
in the Google Cloud console or after deploying the function when using the
gcloud CLI. For functions created with the Cloud Functions API (v2), you specify triggers as part of function deployment. |
You specify triggers as part of function deployment. |
Event types | Support for any event type supported by Eventarc, including 90+ event sources through Cloud Audit Logs. | Direct support for events from 7 sources. |
Retries | For functions created with the Cloud Run Admin API, update the
retry policy
in Eventarc and configure
dead-letter topic
in Pub/Sub. For functions created with the Cloud Functions API v2, you specify retries as part of function deployment with the --retry
flag.
|
You specify retries as part of function deployment with the
--retry flag. |
What's next
- Try the getting started guide for deploying a function in Cloud Run.