HomeArticles

Chapter 7 of Kubernetes cost and autoscaling

What Is GCP Cloud Run Used For? A Practitioner's Guide

What is GCP Cloud Run used for? Stateless containers that scale to zero: where it fits, where it does not, how it compares with Fargate, and how to deploy.

What Cloud Run is good and poor at: scale-to-zero HTTP services versus stateful, very long or network-heavy work.

GCP Cloud Run is used for running stateless containers without managing servers, scaling to zero when idle, and paying only for what you consume. It’s Google’s answer to the “I need to run a container but I don’t want to babysit a cluster” problem.

In this guide I’ll walk you through exactly what Cloud Run is good for, where it falls apart, how it compares to AWS and Azure alternatives, and how it fits both data infrastructure and production AI systems. I’ll also answer the questions everyone asks: is gcp free tier worth it and how to pass gcp associate cloud engineer exam.


Cloud Run in 2026: The Serverless Container That Actually Works

Most people think serverless means functions (AWS Lambda, Google Cloud Functions). They’re wrong. Serverless containers are the sweet spot. You get the portability of Docker without the pain of Kubernetes.

Cloud Run runs your container image on Google’s infrastructure. It automatically scales based on incoming requests. If there’s no traffic, it scales to zero — you pay nothing. A request hits the container, and Cloud Run (sometimes) cold‑starts it in under a second. For recent versions with the “always‑on” CPU allocation feature, cold start is basically gone if you pay the small premium.

The key difference between Cloud Run and its competitors? Pricing model. GCP charges per CPU‑second and memory‑second, rounded to the nearest 100ms. Compare that to AWS Fargate which rounds to the nearest minute. That matters when your service handles bursts of traffic for 10 seconds then sleeps. (Cloud Pricing Comparison: AWS, Azure, GCP)

But let’s be honest — not every workload fits. Cloud Run is best for HTTP‑driven services (APIs, webhooks, small microservices). It’s terrible for long‑running tasks (max 60 minutes per request by default, though you can raise it to 60 minutes with CPU always on). I’ll cover the gotchas later.


Where Cloud Run Shines (and Where It Doesn’t)

It shines when…

  • You have variable traffic. Cloud Run scales from 0 to hundreds of instances in seconds. No pre‑provisioning, no reserved capacity. A chatbot that gets a few requests per day but spikes during product launches is a good fit. Cloud Run handles it without any scaling config — just set max instances to a safe limit.

  • You’re building a stateless API. Anything that processes a request and returns a response fits perfectly. Think REST endpoints, GraphQL, webhook receivers. Each service gets its own container and its own endpoint. Deployment is a single gcloud run deploy command.

  • You need to run small data pipelines. Not the heavy ETL (use Dataflow for that), but transformations that are triggered by HTTP. Example: a service that takes a webhook from Stripe, enriches it with customer data, and writes to BigQuery. That’s three Cloud Run services chained.

  • You want cheap, low‑usage services. This is where is gcp free tier worth it becomes obvious. Cloud Run’s free tier gives you 2 million requests per month and 360,000 CPU‑seconds of compute time. For a hobby project or a demo? That’s effectively free forever. Startups can run an entire MVP on Cloud Run free tier. (Comparing AWS, Azure, and GCP for Startups in 2026)

It doesn’t shine when…

  • You have stateful workloads. Cloud Run is stateless by design. The filesystem is ephemeral — anything written is gone when the container is recycled. You can mount Cloud Storage FUSE or use a sidecar proxy, but it’s hacky. Use GKE or Compute Engine if you need persistent volumes.

  • You need GPU acceleration. Cloud Run doesn’t support GPUs. Period. For AI training or inference with heavy GPU loads, you’re stuck with GKE or AI Platform. CPU‑only inference on Cloud Run works for a small ML model, but latency is much higher than on a GPU.

  • You have long‑running background jobs. Max request timeout is 60 minutes (up from the old 15 minutes). For batch processing that takes hours, look at Cloud Tasks or Batch.

  • You need complex networking. VPC access works, but advanced routing, NAT gateways, and strict egress controls require extra configuration. Cloud Run is designed for public‑facing services. For internal‑only services, you can use Private Services Access but it adds complexity.


Cloud Run vs. The Alternatives: AWS Fargate, Azure Container Instances, and Others

Let’s compare quickly because you’ll see this question everywhere.

AWS Fargate is Amazon’s serverless container platform. It runs on Elastic Container Service (ECS). The big difference: Fargate doesn’t scale to zero. You pay for the minimum amount of compute, even if nothing is using it. You can set a “desired count” of 0, but then the service goes cold and takes minutes to restart. Cloud Run scales to zero instantly and comes back in under a second. (Azure vs AWS vs GCP - Cloud Platform Comparison 2025)

Azure Container Instances (ACI) are fast to start but don’t auto‑scale. You have to manage scaling yourself or use Azure Container Apps (which is much closer to Cloud Run). Container Apps does support scale‑to‑zero and revision management. The pricing structure is similar but GCP’s per‑100ms billing is more granular. A 2025 comparison showed Cloud Run 15% cheaper for typical bursty workloads. (Cloud Pricing Comparison 2026: AWS, Azure, GCP, Oracle)

Google Cloud Functions vs Cloud Run. If your logic is tiny (under 9KB) and you need the fastest cold start, use Functions. For anything bigger — any Docker image — use Cloud Run. Functions have a 60‑second timeout and can’t accept streaming requests. Cloud Run gives you full control over the HTTP stack. A simple rule: if it fits in a single file, maybe use Functions. If you need a framework (FastAPI, Express, Flask), use Cloud Run.

Knative is the open‑source foundation under Cloud Run. If you run on‑prem or multi‑cloud, you can use Knative directly. But the GCP‑managed service removes all the Kubernetes complexity. Knative on AWS EKS works, but ops overhead is high. Cloud Run is worth the lock‑in for the simplicity.


Real‑World Use Cases

1. AI Inference Endpoint for an E‑commerce Recommendation Engine

A microservice takes a list of user actions (clicks, views, adds‑to‑cart) and returns personalized product recommendations. A small TensorFlow model packaged with FastAPI fits well on Cloud Run. During a traffic spike such as Black Friday, Cloud Run scales out containers and back down afterwards, so you pay only for the spike.

2. Webhook Aggregator for Payment Events

A payments team receives webhooks from Stripe, PayPal, and Square and needs to deduplicate, enrich, and forward them to its warehouse. Deploy separate Cloud Run services: one for each payment provider, plus a central router. Each service scales independently. If Stripe has a glitch and sends duplicate events, the deduper catches it and returns 200.

3. Image Processing Pipeline

Users upload profile pictures to Cloud Storage. A notification triggers a Cloud Run service that resizes the image, applies a watermark, and stores the result. Cloud Run can handle the image processing because the container has ImageMagick or Pillow. The job runs in under 5 seconds per image. If no uploads happen for a week, the service scales to zero — no idle cost.

4. Internal Admin Dashboard API

“Why not just run it on a cheap VM?” The answer: because the dashboard is used by a few people during business hours and no one overnight. A VM costs money while idle. Cloud Run scales to zero. The trade‑off is cold start, but with a minimum instance of 1 (costs slightly more), it’s fine.


Pricing: Is GCP Free Tier Worth It?

Short answer: absolutely, if your traffic is low.

Long answer: GCP’s free tier for Cloud Run includes 2 million requests per month, 360,000 CPU‑seconds, 360,000 memory‑seconds, and 1GB outbound data. That’s enough for a personal blog backend, a small API, or a prototype.

But the free tier has limits. You can’t use CPU‑always‑on (that costs extra). You can’t set custom VPC connectors. Maximum concurrency is limited. For a production system, you’ll need to move to paid — but paid is still cheap. A single container with 256MB RAM and 1 vCPU running 24/7 costs about $20/month. A similar‑sized AWS Fargate task costs $30.

(Cloud Pricing Comparison: AWS, Azure, GCP) shows that for the same workload of 5 million requests/month with 1s average processing, Cloud Run was 22% cheaper than Azure Container Apps and 35% cheaper than AWS Fargate.

The real question: is gcp free tier worth it for learning? Yes. You can deploy real apps without a credit card (though you need billing enabled). Pass the Associate Cloud Engineer exam? Cloud Run is a core topic — you’ll need to know how to deploy, scale, and connect to other GCP services. The free tier lets you practice without cost.


How to Pass the GCP Associate Cloud Engineer Exam: Cloud Run Tips

Cloud Run topics for the GCP Associate Cloud Engineer exam: deploy flags, scaling, concurrency, IAM and cold starts

If you’re studying for the exam, here’s what you need to know about Cloud Run.

  • Understand the difference between Cloud Run (fully managed) and Cloud Run for Anthos. The exam focuses on fully managed. Know that Cloud Run on GKE exists but is less common.

  • Deploying a container. Know how to use gcloud run deploy, set environment variables, assign a service account, and configure concurrency. Practice the commands.

  • Scaling behavior. Request‑driven scaling, min/max instances, concurrency per instance. The exam will ask: if you set concurrency to 1, how many instances will you get? (Answer: one per request up to max instances).

  • Connecting to other services. Understand VPC connectors for private networking (to reach Cloud SQL, Memorystore). Know that Cloud Run can’t connect to a VPC without a connector.

  • Security. Service account permissions, IAM roles (roles/run.invoker, roles/run.developer), and how to use Secret Manager for environment variables.

  • Cold starts. The exam may ask about strategies to reduce cold starts: min instances, CPU always on, or using Cloud Functions for rarely used endpoints.

  • Knative. Not required for the exam, but understanding that Cloud Run is Knative helps.

The official Google practice exams are good. I also recommend building a simple app end‑to‑end: containerize a FastAPI app, deploy, connect to Cloud SQL via VPC connector, set up CI/CD with Cloud Build. Do that three times and you’ll pass the Cloud Run section easily.


A Practical Deployment: Step‑by‑Step with Code

Here’s how to deploy a production‑ready service.

Step 1: The Dockerfile

FROM python:3.11-slim

WORKDIR /app

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

# Run the FastAPI app with Gunicorn and Uvicorn workers
CMD exec gunicorn --bind :$PORT --workers 4 --worker-class uvicorn.workers.UvicornWorker main:app

Use Gunicorn with Uvicorn workers because Cloud Run expects a single HTTP server process. Setting $PORT is required — Cloud Run passes the port as an environment variable.

Step 2: The gcloud run deploy command

gcloud run deploy event-inference   --image gcr.io/my-project/event-inference:1.0.0   --platform managed   --region us-central1   --memory 2Gi   --cpu 2   --concurrency 80   --min-instances 1   --max-instances 100   --set-env-vars "MODEL_PATH=/models/v3.pb"   --service-account [email protected]   --vpc-connector my-vpc-connector   --allow-unauthenticated

Key flags explained:

  • --min-instances 1 keeps one container warm. This eliminates cold start for the first request. Cost is about $15/month extra, but worth it for production.
  • --concurrency 80 tells Cloud Run to send up to 80 requests to the same container. For AI endpoints, tune this based on CPU/memory usage. Too high leads to tail latency.
  • --vpc-connector is needed to reach Cloud SQL and Redis instances.

Step 3: Handling requests with proper health checks

from fastapi import FastAPI, Request
import time

app = FastAPI()

@app.get("/health")
def health():
    return {"status": "ok"}

@app.post("/predict")
async def predict(request: Request):
    body = await request.json()
    start = time.time()
    result = run_inference(body["input"])
    elapsed = time.time() - start
    # Log latency for monitoring
    print(f"Inference took {elapsed*1000:.1f}ms")
    return {"result": result}

Cloud Run uses HTTP health checks (/health) for instance readiness. Always implement /health returning 200 before doing any heavy work. Log structured JSON for Cloud Logging.

Step 4: Automate with Cloud Build

steps:
- name: 'gcr.io/cloud-builders/docker'
  args: ['build', '-t', 'gcr.io/$PROJECT_ID/inference:$SHORT_SHA', '.']
- name: 'gcr.io/cloud-builders/docker'
  args: ['push', 'gcr.io/$PROJECT_ID/inference:$SHORT_SHA']
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
  entrypoint: 'gcloud'
  args:
  - 'run'
  - 'deploy'
  - 'event-inference'
  - '--image=gcr.io/$PROJECT_ID/inference:$SHORT_SHA'
  - '--region=us-central1'

Every push to main builds, pushes, and deploys. Rollback is a single command: gcloud run deploy event-inference --image previous-tag.


Limitations and Gotchas: What They Don’t Tell You

Cold Starts Still Happen (Even with Min Instances)

Setting --min-instances 1 keeps one container alive. But if traffic bursts beyond that container’s concurrency limit, new containers are created — and those have cold starts. For a 500MB container, that’s 1-3 seconds. For AI models loaded at startup, it can be 10+ seconds. Mitigation: use --min-instances with a number that covers your base load, and accept cold starts for spikes. Or use CPU always‑on to keep containers alive longer.

No Native WebSockets (as of July 2026)

Cloud Run supports HTTP/1.1 and gRPC. WebSockets? Not officially. You can hack it with streaming responses (Server‑Sent Events), but full bidirectional WebSocket isn’t supported. Use GKE if you need it. Google has hinted at WebSocket support in preview, but we’re still waiting.

Container Must Start HTTP Server in Under 4 Minutes

The startup health check failure threshold is 4 minutes. If your container takes longer to boot (loading large models, downloading data), you need to set --startup-cpu-boost and --timeout appropriately. Even then, 10+ minute startups are risky. Pre‑download models to a persistent volume (Cloud Storage FUSE) to avoid cold loading.

Concurrent Requests Are Limited

Max concurrency per container is 80 (for second‑gen execution environment). If you need more, raise the container’s CPU/memory or add more max instances. But high concurrency + heavy compute = queueing. Higher concurrency pushes p99 latency up. Tune per workload.

Egress Costs

Outbound data from Cloud Run to the internet costs $0.12/GB. That’s standard for GCP. But if your service is a proxy that streams large responses, bandwidth cost overwhelms compute cost.

No Built‑in Stateful Storage

You can’t write to local disk and expect it to persist. Use Cloud Storage for files, Cloud SQL for relational data, Firestore for NoSQL. Sidecar containers (like Cloud SQL Proxy) work via VPC connectors but add complexity.


The Future: Cloud Run and Production AI Systems

Google is investing heavily in Cloud Run as the platform for modern AI services. In 2026, they announced support for NVIDIA GPUs (in preview). That changes the game. You’ll be able to run GPU‑accelerated inference on Cloud Run without managing GPUs.

Also: event‑driven Cloud Run triggers from Pub/Sub, Cloud Storage, even Kafka via Confluent connector. This makes Cloud Run the glue for microservice architectures. A real‑time anomaly detection system is a good example: events arrive on Pub/Sub, trigger a Cloud Run container that runs a fast ML model, and write alerts to Bigtable. All serverless.

The question what is gcp cloud run used for will have an even bigger answer in two years. It’s not just “serverless containers” anymore — it’s the compute layer for data infrastructure and AI. And it’s getting cheaper and faster every quarter.


FAQ

Q: Can I run a database on Cloud Run?
No. Cloud Run is for stateless containers. Use Cloud SQL, Memorystore, or Firestore for state.

Q: How does Cloud Run handle multiple versions?
You can deploy revisions (versions) and route traffic percentage‑wise to each. For example, 80% to v1, 20% to v2 for canary deployments.

Q: Is Cloud Run good for real‑time chat applications?
Not for WebSocket‑based chat. But if you use HTTP long polling or Server‑Sent Events, it works.

Q: What programming languages are supported?
Any language that runs on Linux with an HTTP server. Node.js, Python, Go, Java, Ruby, .NET — all work. The container must listen on $PORT.

Q: Can I use Cloud Run for batch processing?
Not natively. Cloud Run has a 60‑minute request timeout. For batch, use Cloud Batch or Cloud Workflows to orchestrate multiple Cloud Run calls.

Q: How do I learn more?
Start with the official Quickstart, then try deploying your own Docker image. The GCP Associate Cloud Engineer exam is a great structured path — and yes, how to pass gcp associate cloud engineer exam is mostly about hands‑on practice. Build three services, break them, fix them. That’s how you learn.

Q: Is gcp free tier worth it for Cloud Run?
Yes. For learning and low‑traffic projects, it’s free. You can run a blog backend, a personal API, or a prototype for months without paying. Just watch your egress costs.


Closing Thoughts

Cloud Run at a glance: zero idle cost, billing in 100 ms steps, and 2 million free requests a month

Cloud Run isn’t perfect. But for the majority of microservices, it’s the best deployment option on GCP. The combination of scale‑to‑zero, per‑100ms billing, and fully managed infrastructure is hard to beat.

If you haven’t tried Cloud Run, start with a simple API. Containerize it. Deploy it. Watch it scale to zero. Then ask yourself: what is gcp cloud run used for in my stack? The answer might surprise you.

Want to talk this through?

Sivaro Enterprise →