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

Not Just Similar — Literally the Same Underlying Service
Google's own real documentation now calls 2nd-generation Cloud Functions "Cloud Run functions". Deploying a 2nd-gen function doesn't run it on some separate functions-only runtime — it's "automatically built as a container and deployed as a Cloud Run service." Cloud Functions 2nd gen is a convenience layer for going from source code straight to a running Cloud Run service, not a genuinely separate compute product underneath.

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

Property1st Gen2nd Gen (Cloud Run functions)
Max timeout9 minutes60 min (HTTP-triggered); 9 min (event-driven)
Max resources8 GB RAM / 2 vCPU16 GB RAM / 4 vCPU
Concurrency per instance1 request at a timeUp to 1,000 concurrent requests
Event sources7 direct sources90+ sources via Cloud Audit Logs
Underlying infrastructureLegacy functions runtimeCloud Run itself

Three Serverless Compute Models, Compared

PropertyAWS LambdaAzure FunctionsGCP Cloud Run / Functions
Max execution timeHard 15-minute ceiling, every planUnbounded on Flex Consumption/Premium/Dedicated60 minutes (HTTP), any Cloud Run service
Relationship to containersLambda and Fargate are separate servicesFunctions and Container Apps are separate, related services2nd-gen functions are Cloud Run services
Scale-to-zeroYes (Lambda itself is inherently request-driven)Yes, on Consumption planYes, on Cloud Run's own default scaling

Hands-On Exercises

Exercise 1

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 solution
Exercise 2

A 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 solution
Exercise 3

A 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 solution

Chapter 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