Cloud Run vs GKE vs Cloud Functions: a decision guide

Pick the platform by workload shape, not habit: when Cloud Run services, Cloud Run functions, jobs or GKE Autopilot fit, and how to move between them later.

Published

Updated

Reading time

11 min

My default for a new backend on Google Cloud is a Cloud Run service, and every other option has to earn its place by naming something a service cannot do. That is a narrower claim than "serverless is better". A cluster is the right answer when you need Kubernetes itself, a job is the right answer when the work ends, and a function is the right answer when the code is one handler. The mistake is choosing on preference and then discovering the workload's shape afterwards, so this guide decides by shape, with the questions in a fixed order. The default comes from running small services on Cloud Run, roughly ten at first and 32 today, as the only engineer on a large-scale social platform I'm building.

It compares Cloud Run services, Cloud Run functions, Cloud Run jobs, Cloud Run worker pools and GKE (Autopilot and Standard). Startup latency is a separate topic, covered in Cloud Run cold starts.

Names first#

Product names moved, so the vocabulary needs fixing before the comparison. According to the Cloud Functions version comparison, what used to be Cloud Functions (2nd gen) is now Cloud Run functions, and the original generation is Cloud Run functions (1st gen). A current function is a Cloud Run service whose container Google builds from your source, with a small framework that turns an HTTP request or an event into a call to your handler.

Two practical consequences. First, you can deploy these functions with gcloud run deploy against the Cloud Run Admin API or with gcloud functions deploy against the Cloud Functions v2 API, and the same page says a function created through the Cloud Run Admin API cannot be modified through the Cloud Functions API. Pick one path per function and stay on it. Second, 1st gen is not a candidate for new work: it handles one concurrent request per instance, where the current generation supports concurrency and much longer HTTP timeouts. In the rest of this article "function" means the current generation.

The options side by side#

Trade-offsScales to zeroAutoscalingOperational weight
Cloud Run serviceA container, or source built into oneYes (Strong)By request load (Strong)Low (Strong)
Cloud Run functionSource and an entry point, one handlerYes (Strong)By request load (Strong)Lowest (Strong)
Cloud Run jobA container that runs to completionYes (Strong)Per execution (Depends)Low (Strong)
Cloud Run worker poolA container that pulls work continuouslyNo (Weak)You set the count (Weak)Low (Depends)
GKE AutopilotKubernetes manifests, Google-managed nodesNo (Weak)Pod autoscaling (Strong)Medium (Depends)
GKE StandardKubernetes manifests plus node poolsNo (Weak)You manage nodes too (Depends)High (Weak)
Table 1— Deployment units and what each is built for

Limits matter more than adjectives, but the full table of limits is on the official pages and changes, so I keep only the few that decide a choice:

  • Request duration. Cloud Run services accept request timeouts of up to 60 minutes (request timeout page, default 5 minutes). Event-driven functions are capped lower, at 9 minutes per the version comparison. Work that approaches either belongs in a job or a queue.
  • Concurrency. A service instance handles up to 80 concurrent requests by default and more if you raise it (concurrency page). That is why a service is cheaper than one-request-per-instance models for I/O-bound code.
  • Sidecars and GPUs. Cloud Run runs multiple containers per instance and supports GPUs, so neither alone forces you onto a cluster.
  • Quotas. Memory, vCPU and request-size ceilings sit on the quotas page. Check them against your heaviest request before committing, not against the average one.

Questions in order#

Ask these in sequence. Each yes ends the search, and the final no lands on a Cloud Run service.

Ask the questions in order. Each yes ends the search; the final no lands on a Cloud Run service, the default.

Does it need Kubernetes itself? Not "might Kubernetes be nice". A concrete need: a third-party operator you cannot replace, a DaemonSet that must run on every node, workloads that depend on Kubernetes APIs, or scheduling and networking behaviour Cloud Run does not expose. Then GKE is the answer, and Autopilot is where to start. The Autopilot overview describes Google managing nodes, scaling and upgrades, and lists the trade: privileged workloads need an allowlist, host access is restricted and DaemonSets are limited. If a requirement collides with those restrictions, Standard is the escape hatch, and you have just learned that you needed node control.

Does it run to completion? A migration, a nightly export, a bulk reprocessing run is a Cloud Run job: no endpoint, per-task retries, and fan-out across tasks via CLOUD_RUN_TASK_INDEX and CLOUD_RUN_TASK_COUNT. Forcing batch work through an HTTP endpoint with a long timeout is a smell. Cloud Run jobs vs services for batch work goes deeper.

Does it pull work continuously? A consumer that reads a queue or stream and receives no inbound requests is awkward for a service, because a service with nothing to serve is one the platform scales away. Worker pools exist for this: no load-balanced endpoint, no autoscaling, and you choose the instance count. When the source is a Pub/Sub subscription I still usually prefer push delivery into an ordinary service, which keeps scale-to-zero and autoscaling; the failure patterns in dead-letter queues as a safety net apply either way.

Is it one small handler? One event type or one HTTP route with little shared code is what functions are for. The honest test is whether you would be content for it to be its own repository with its own release cycle. If it shares models and middleware with six other handlers, it belongs in a service.

Everything else is a Cloud Run service: an API with several routes, a web application, a webhook receiver, anything that speaks HTTP and benefits from autoscaling. The container is the most portable unit available, and a service adds request-driven scaling, revisions with traffic splitting and no cluster to look after.

Splitting one thing into two#

The same question applies inside a system: when does a component earn its own deployable? The only reason I accept is that it differs from its neighbours in one of three ways. It scales on a different curve (a request-driven API next to a batch renderer), it fails differently (an experimental integration that must not take down checkout), or it has a different owner who releases on a different schedule. Without one of those, a separate service adds a network hop, a deploy pipeline and an on-call surface for no benefit, and a module boundary inside one service gives most of the isolation for none of the cost. My own split rests on the second reason: as the only engineer I cannot afford a platform-wide outage from a typo in a corner feature, so a bad deploy should break one capability, and small services let me ship in minutes, dozens of times a week, without coordinating anything. What made that many services affordable was scale-to-zero billing. Ten small services that each sleep when idle cost roughly what one sleeping monolith costs. The inverse also holds: a function that grew a second route and a shared module should become a service.

What each choice looks like#

A Cloud Run service#

terminalbash
gcloud run deploy orders-api \
  --image europe-west1-docker.pkg.dev/my-project/apps/orders-api:2026-10-13 \
  --region europe-west1 \
  --service-account orders-api@my-project.iam.gserviceaccount.com \
  --min-instances 0 \
  --max-instances 20 \
  --concurrency 80 \
  --timeout 60 \
  --memory 512Mi \
  --cpu 1 \
  --no-allow-unauthenticated

Each flag is a decision. A dedicated service account keeps permissions narrow (see GCP IAM least privilege). --max-instances caps the blast radius of a bug or an attacker and, more often, protects a downstream database with a fixed connection limit; size it against the weakest dependency, not against what the platform would allow. --timeout 60 is deliberately far below the 300-second default, since a request still unanswered after a minute is usually a bug.

If the service does work after sending its response, you need instance-based billing (--no-cpu-throttling, described on the billing settings page). Under the default request-based billing, CPU is only allocated while a request is being processed, so work scheduled after the response can be starved and appear to finish only when another request arrives. If the work matters, move it to a job or a queue instead.

A Cloud Run function#

terminalbash
gcloud functions deploy resize-avatar \
  --gen2 \
  --runtime nodejs24 \
  --region europe-west1 \
  --source . \
  --entry-point resizeAvatar \
  --trigger-http \
  --no-allow-unauthenticated \
  --service-account avatars@my-project.iam.gserviceaccount.com \
  --max-instances 10 \
  --memory 512Mi \
  --timeout 60s

For a Pub/Sub trigger, replace the HTTP flags with --trigger-topic orders-paid. The nodejs24 runtime is listed as generally available on the runtime support page; gcloud functions runtimes list prints what your project can use today. Runtimes are retired on a published schedule, so a function brings a deprecation calendar that a container you built yourself does not.

src/index.tsts
import { cloudEvent } from "@google-cloud/functions-framework";
 
cloudEvent("sendReceipt", async (event) => {
  const message = event.data as { message?: { data?: string } };
  const payload = JSON.parse(
    Buffer.from(message.message?.data ?? "", "base64").toString("utf8"),
  );
  await sendReceiptEmail(payload.orderId);
});

Event delivery is at least once, so sendReceiptEmail must tolerate duplicates. The approach in idempotent Pub/Sub consumers carries over unchanged.

A minimal GKE Autopilot cluster#

When the questions send you to Kubernetes, start as small as the platform allows (creation guide):

terminalbash
gcloud container clusters create-auto platform-eu \
  --location=europe-west1 \
  --project=my-project \
  --release-channel=regular
 
gcloud container clusters get-credentials platform-eu \
  --location=europe-west1 \
  --project=my-project

Then deploy the image you would have given Cloud Run. Autopilot provisions capacity from what your manifests request, so the resources.requests block in the Deployment is the thing you are really configuring.

CostTwo different billing meters

Prices differ by region and change, so read the Cloud Run and GKE pricing pages. The mechanism is what matters. Cloud Run services bill for the CPU and memory instances use, by default only while handling requests, starting up or shutting down, so an idle service costs close to nothing; every minimum instance you configure keeps billing, as the minimum instances page explains. GKE Autopilot bills pods by the resources they request whether or not they are busy, so a running cluster is never at zero. Take a hypothetical service that receives traffic two hours a day: on Cloud Run it costs about two hours of compute, on Autopilot a full day of pod requests, and the gap repeats for every staging, preview and demo environment you replicate.

Moving between platforms#

The container is the portable unit, which is the best argument for treating the choice as reversible. A function that outgrows its shape gets a Dockerfile, keeps the Functions Framework as its entry layer if you like, and is deployed with gcloud run deploy --image; the handler code does not change, but decide which API manages it, per the naming section.

Service to GKE means building the image once and referencing it from a Deployment. gcloud run services describe orders-api --region europe-west1 --format export prints the service as YAML, a useful checklist of the CPU, memory, concurrency, environment variables and secrets to reproduce. The work is everything around the pod: ingress, autoscaling, identity and observability. Move one service first and live with it. GKE to a service is easier than it sounds for stateless workloads; watch for Kubernetes DNS service discovery and node-local state.

What makes any of these moves cheap is a disciplined container contract: configuration from environment variables, structured JSON logs on stdout (structured logging on a budget), listen on PORT, handle SIGTERM, no durable state on local disk. Code written for one request at a time also breaks quietly on concurrent platforms through module-level mutable state or a shared connection used as if it were exclusive; either fix the code or set --concurrency 1 on purpose and accept more instances. Connection pooling for tiny services covers where those bugs usually surface first.

Recommendation per situation#

  • A small team shipping a product backend. Cloud Run services for everything request-driven, jobs for batch, a worker pool only for continuous pull consumers. No cluster until a named requirement demands one. What keeps 32 services manageable for me is the tooling around them: one TypeScript monorepo, CI that builds and deploys only the service that changed, and a managed API gateway in front that checks authentication so no service reinvents it.
  • A single event handler with one owner. A function. Consolidate related handlers into a service before you have a dozen pipelines and runtime upgrades to track.
  • A team that already runs Kubernetes well, with a platform group and an on-call rotation that understands it: keep consistent with it. One platform operated well beats two operated inconsistently, and software that ships only as a Helm chart or operator has already answered the first question.
  • Spiky traffic with long idle gaps, many environments. Cloud Run, because the idle floor is the deciding cost. Set --max-instances on everything. During my closed beta, the whole infrastructure bill came to between 20 and 50 euros a month, less than a night out, which is the outcome this default is meant to produce.
  • A function that has done one job quietly for a year. Leave it. Rewriting it to match a diagram is the same mistake as adopting a cluster early: effort on structure the workload never asked for.
Share
All articles →

Batch work behaves badly behind an HTTP endpoint. Compare Cloud Run jobs and services on retries, parallelism and exit codes, and shard work across tasks.

12 min

Measure which phase of a Cloud Run cold start is slow, match it to the lever that shortens it, and pay for warm instances only where the latency earns it.

15 min

Start with a budget that emails a monitored channel, then add a Pub/Sub relay, usage alerts and a heartbeat that notices silence when that is worth building.

10 min