Difference between GCP 1st gen and 2nd gen Cloud Functions

What is Cloud Functions

Cloud Functions in GCP is a serverless execution environment for building and connecting cloud services. Cloud functions is similar to AWS Lambda and Azure Functions.

With Cloud Functions you can write functions that are triggered when events are emitted from your cloud infrastructure and services. Along with emitted events Cloud functions can be triggered by an HTTP request. Below are the some of the example events that can trigger a Cloud function.

  • Events from Pub/Sub
  • Events from CLoud Storage

2nd gen Cloud Functions

In August, 2022 Google Cloud announced the general availability of the 2nd generation of Cloud Functions. With this announcement now Cloud Functions offers two product versions Cloud Functions (1st gen), the original version, and Cloud Functions (2nd gen), a new version built on Cloud Run and Eventarc to provide an enhanced feature set. With the general availability of the 2nd generation of Cloud Functions you can start using 2nd gen Cloud Functions for new workloads, while continuing to use your existing 1st gen Cloud Functions.


See Also: How to create 2nd gen Cloud functions

See Also: How to create 1st gen Cloud functions

1st gen vs 2nd gen comparison

Cloud Functions (2nd gen) is built on Cloud Run and Eventarc and have an enhanced infrastructure and broader event coverage. Let's have a look the feature comparison between 1st gen and 2nd gen.

Traffic splitting


  • Not support in Cloud Functions (1st gen)
  • Supported in Cloud Functions (2nd gen). Traffic splitting enables you to split traffic between different revisions or roll your function back to a prior revision.

Learn more about traffic splitting in Cloud Functions: traffic-splitting

Request timeout


  • Up to 9 minutes in Cloud Functions (1st gen)
  • Up to 9 minutes for event-triggered functions and Up to 60 minutes for HTTP-triggered functions in Cloud Functions (2nd gen).

Learn more about request timeout in Cloud Functions: timeout

Instance size


  • Up to 8GB RAM with 2 vCPU in Cloud Functions (1st gen)
  • In Cloud Functions (2nd gen) you can leverage up to 16GB of RAM and 4 vCPUs instances.

Event types


  • Cloud Functions (1st gen) supports for events from 7 sources, refer this to check supported events.
  • In Cloud Functions (2nd gen) support for any event type supported by Eventarc, including 90+ event sources via Cloud Audit Logs.

Learn more about event triggers in Cloud Functions: event triggers

Image registry


  • Cloud Functions (1st gen) supports Container Registry or Artifact Registry.
  • Cloud Functions (2nd gen) supports Artifact Registry only.

Concurrency


  • Cloud Functions (1st gen) supports 1 concurrent request per function instance.
  • Cloud Functions (2nd gen) can support up to 1000 concurrent requests per function instance.

Learn more about Cloud Functions concurrency: concurrency

CloudEvents


  • Cloud Functions (1st gen) supports creating CloudEvent functions only in Ruby, .NET, and PHP runtimes.
  • Cloud Functions (2nd gen) supports creating CloudEvent functions in all language runtimes.

Learn more about CloudEvents: CloudEvents


Category: GCP