Author:
Generate a follow-up sub-lesson on any aspect of this topic
Author:
Generate a follow-up sub-lesson on any aspect of this topic
Cloud Run functions now run on Cloud Run itself, so the choice is about packaging and control, not infrastructure. Compare workload fit, scaling, operations, and cost to pick the right serverless platform for your team.
Cloud Run vs Cloud Functions looks like a product decision, but since August 21, 2024 it is mostly a question of how much of the container you want to own. Cloud Run functions, the successor to Cloud Functions 2nd gen, are deployed as Cloud Run services under the hood. The real choice is between a function-shaped abstraction and a container you control.
Cloud Functions fits small, single-purpose handlers. Think of a thumbnail generator that fires when a file lands in Cloud Storage, or a handler reacting to a Pub/Sub message. Events through Eventarc, including events from many Google Cloud services via Cloud Audit Logs, are first-class triggers.
The picture below shows the three ways to run code on Cloud Run.
Cloud Run fits anything shaped like an application. A FastAPI or Express API, a Rails or Django site, or a service with several routes belongs in a container. For batch work, Cloud Run Jobs cover the cases where no request is involved at all.
Glue versus apps If the code is one handler reacting to one event, use a function. If it has routes, shared state, or its own startup logic, use a service.
With functions, you hand over source code and pick a supported runtime. Google builds the container for you and you point to an entry point. That is fast, but you work inside the supported language list and the function signature.
Cloud Run accepts any container, so you choose the language version, system packages, and framework. The tradeoff is that you own the Dockerfile and its upkeep. You can also deploy from source code, which narrows the gap.
The table below compares the two side by side.
| Dimension | Cloud Run functions | Cloud Run services |
|---|---|---|
| Input | Source plus entry point | Container image or source |
| Runtime | Supported runtimes only | Anything that listens on a port |
| Triggers | Built in at deploy | Wired up with Eventarc or Pub/Sub |
| Best for | Single handlers | Full applications |
Concurrency is where the old and new worlds split. Cloud Functions 1st gen handled one request per instance. Cloud Run functions and Cloud Run services support up to 1000 concurrent requests per instance, with a default of 80 for services deployed from the console. One instance serving many requests means fewer cold starts and a smaller bill, provided your code is safe under parallel load.
Timeouts matter too. Cloud Run services default to 5 minutes and extend to 60 minutes. HTTP-triggered functions also reach 60 minutes, but event-driven functions created with the v2 API cap at 9 minutes. For anything longer, use Cloud Run Jobs.
Timeouts leak When a request times out, Cloud Run returns a 504 but the instance keeps processing. Set the timeout above expected runtime and return early when time runs short.
Because functions are now Cloud Run services, they inherit Direct VPC, GPUs, volume mounts, and traffic splitting. The older 1st gen lacks traffic splitting, so gradual rollouts are not an option there. Instance size also differs: functions on Cloud Run go up to 16 GiB RAM with 4 vCPU, against 8 GB with 2 vCPU on 1st gen, while Cloud Run services can be configured up to 32 GiB and 8 vCPU.
Governance has one wrinkle. A function created through the Cloud Run Admin API can only be managed through that API. Functions made with the Cloud Functions v2 API can be detached so they stay inside the run.googleapis.com boundary, which matters for Assured Workloads. Deployment roles differ too. The Cloud Run model uses roles/run.sourceDeveloper for deployment, while 1st gen uses roles/cloudfunctions.developer.
Cloud Run functions and Cloud Run services run on the same engine, so they share a pricing model. The Free Tier for request-based billing includes 2 million requests per month. Check the Cloud Run pricing page for current rates and for instance-based billing.
The 1st gen model handles one request per instance. A chatty API on 1st gen needs an instance for every concurrent request, while the same API on Cloud Run can share one instance across many.
Teams most often regret starting with a function and then bolting on routes, custom binaries, or long processing until the function is a poorly shaped app. The other regret is a container for a ten-line event handler, which adds a Dockerfile nobody wanted.
The picture below shows the checklist as four steps.
When in doubt, start with Cloud Run. Because functions already live there, moving up later is a small step. Take your most uncertain workload, list its triggers and longest runtime, and run it through this checklist before the first deploy.
These are the points to remember from this guide.