GCP Cloud Functions (2nd generation renamed “Cloud Run Functions”)
Google Cloud Functions is, in most ways, the counterpart of AWS Lambda on Google Cloud Platform (GCP). These services are both serverless computing platforms, allowing you to execute your code in response to events without the need to provision or manage servers.
You write your functions in supported languages like Node.js, Python, Go, Java, .NET, and others, and Cloud Functions automatically scales to handle incoming events. You simply upload your code, define a trigger, and Cloud Functions handles the rest.
Confusingly the 2nd gen of Cloud Functions was renamed “Cloud Run Functions”, see: Cloud Run functions (formerly known as Cloud Functions) release notes | Cloud Run functions Documentation | Google Cloud. Presumably to unify Cloud Functions with Cloud Run as unified functionality. More details: Google Cloud Functions is now Cloud Run functions | Google Cloud Blog.

Key Features & Benefits of GCP Cloud Functions
- Event-Driven Triggers: Trigger functions from Cloud Storage, Pub/Sub, HTTP requests, and more.
- Automatic Scaling: Handles workloads of any size without provisioning infrastructure.
- Precise Billing: Pay only for the execution time rounded up to the nearest 100 milliseconds (Cloud Run Functions 2nd gen). The details of pricing for gen 1 “Cloud Functions” differs a little, see: Pricing Overview | Cloud Run functions Documentation | Google Cloud.
- Integration: Works reasonably seamlessly with other GCP services like BigQuery, Firebase, and Stackdriver.
Best Practices
- Ensure stateless functions for optimal performance and scalability.
- Use Cloud Functions for ephemeral workloads and avoid maintaining persistent state.
- Leverage monitoring for insights into performance and execution metrics.
- Cloud Functions is ideal for lightweight, event-triggered applications that demand simplicity and rapid scaling without server management.
Real-world Cloud Functions / Cloud Run Functions Use Cases
- Image Transformation: Process and transform images uploaded to Cloud Storage. For example, an e-commerce site uploads product images; Cloud Functions generates thumbnails for faster page loads.
- Real-Time Data Processing: Handle real-time metric streams from Pub/Sub or other event sources (even IoT devices). For example, a logistics company app that tracks vehicle locations and uses Cloud Functions to calculate real-time distances and update delivery ETAs.
- API Backends for mobile or web apps: Create lightweight, event-triggered REST APIs or webhooks. For example, a food delivery app could use Cloud Functions as a backend for customer order placement, status updates, and notifications.
- Streaming Data Processing: Validate, filter, and transform data from streaming sources like Pub/Sub or BigQuery.
- Background Task Automation: Automate workflows, notifications, or database updates triggered by events. Can be used with Google Cloud Scheduler to perform routine tasks by process, e.g. a news aggregation platform could scrape and update trending articles hourly.