Cloud Functions & Cloud Run
GCP Fundamentals
Chapter 7 · Cloud Functions & Cloud Run
AWS Fundamentals Chapter 7 covered Lambda and its real, hard 15-minute execution ceiling. Azure Fundamentals Chapter 7 covered Azure Functions, whose higher hosting plans remove that ceiling almost entirely. GCP's own serverless story goes further than either — its two compute services aren't just similar, they're architecturally the same thing.
Cloud Run: A Fully Managed Container Platform
Cloud Run runs your code as a real container — no cluster to create, no infrastructure to manage. It supports deploying an existing container image directly, or a real source-based deployment (Go, Node.js, Python, Java, .NET, Ruby) where the platform builds the container for you automatically.
- Scaling — real, fast request-based autoscaling up to thousands of instances, with genuine scale-to-zero: if no requests arrive, even the last instance is removed. Minimum instances can be configured to avoid this where cold starts matter.
- Timeout — a real default of 5 minutes, extendable up to a real maximum of 60 minutes.
- Billing — two real models: request-based (pay only while actively processing a request, nothing while idle) or instance-based (pay for an instance's full lifetime, no per-request fee).
A Real, Major Structural Finding: Cloud Functions 2nd Gen Is Cloud Run
This is a real, deeper architectural merge than either AWS (Lambda and Fargate are genuinely separate compute engines under the hood) or Azure (Azure Functions and Container Apps are related but distinct services) offer. On GCP, once you're on 2nd gen, "function" and "container service" describe the same real deployed artifact viewed two different ways.
1st Gen vs. 2nd Gen
| Property | 1st Gen | 2nd Gen (Cloud Run functions) |
|---|---|---|
| Max timeout | 9 minutes | 60 min (HTTP-triggered); 9 min (event-driven) |
| Max resources | 8 GB RAM / 2 vCPU | 16 GB RAM / 4 vCPU |
| Concurrency per instance | 1 request at a time | Up to 1,000 concurrent requests |
| Event sources | 7 direct sources | 90+ sources via Cloud Audit Logs |
| Underlying infrastructure | Legacy functions runtime | Cloud Run itself |
Three Serverless Compute Models, Compared
| Property | AWS Lambda | Azure Functions | GCP Cloud Run / Functions |
|---|---|---|---|
| Max execution time | Hard 15-minute ceiling, every plan | Unbounded on Flex Consumption/Premium/Dedicated | 60 minutes (HTTP), any Cloud Run service |
| Relationship to containers | Lambda and Fargate are separate services | Functions and Container Apps are separate, related services | 2nd-gen functions are Cloud Run services |
| Scale-to-zero | Yes (Lambda itself is inherently request-driven) | Yes, on Consumption plan | Yes, on Cloud Run's own default scaling |
Hands-On Exercises
A developer deploys a 2nd-generation Cloud Function and later wants to view or manage it directly through the Cloud Run console instead of the Cloud Functions console. Explain, in your own words, whether this is possible, and why.
📄 View solutionA team needs an event-driven function (not HTTP-triggered) to run for up to 20 minutes on 2nd-generation Cloud Functions. Explain, in your own words, whether this is possible, and what real limit stands in the way.
📄 View solutionA team migrating from AWS explains that on Lambda, moving past the 15-minute execution ceiling meant switching to an entirely different service (Fargate). Explain, in your own words, whether the equivalent move on GCP - going from a short function to a long-running container workload - requires switching services in the same way.
📄 View solutionChapter 7 Quick Reference
- Cloud Run — fully managed containers, real scale-to-zero, up to 60-minute timeout, request-based or instance-based billing
- Real, major finding: 2nd-gen Cloud Functions is literally called "Cloud Run functions" and deploys as a real Cloud Run service underneath
- 1st gen: 9-min max, 1 concurrent request, 8GB/2vCPU. 2nd gen: 60-min max (HTTP), 1,000 concurrent, 16GB/4vCPU
- Genuinely deeper merge than AWS (Lambda/Fargate separate) or Azure (Functions/Container Apps separate) offer