Training Trains Group · one group, 3 companies
← Knowledge Hub

Google Cloud · Compute

Google Cloud Run

Run stateless containers that scale automatically, including down to zero, without managing servers.

What is it?

Cloud Run runs a container image you provide and exposes it over HTTP (or as a background worker via Pub/Sub triggers). Google Cloud handles provisioning, scaling the number of running instances up and down — including to zero when there’s no traffic — and load balancing between them.

Why it matters

It removes most of the operational overhead of running containers: no cluster to size, patch, or pay for while idle. You package your app as a container once, and it runs the same way locally, in CI, and in production.

Business use cases

  • HTTP APIs and backend services with variable or unpredictable traffic
  • Web applications that need to scale to zero between bursts of use to save cost
  • Background job processing triggered by Pub/Sub messages or Cloud Scheduler
  • Internal tools and admin dashboards that don’t need to run 24/7

How it works

You build a container image (via a Dockerfile or Buildpacks) and deploy it as a Cloud Run "service." Google Cloud assigns it a URL, and each incoming request is routed to an existing or newly-started container instance. You configure concurrency (requests per instance), CPU/memory, min/max instance counts, and whether it should scale to zero when idle.

When to use it

  • Your workload is stateless (or keeps state in an external database/cache, not on local disk)
  • Traffic is bursty, unpredictable, or has meaningful idle periods
  • You want container portability without managing a Kubernetes cluster

When not to use it

  • You need a persistent filesystem, WebSocket connections lasting hours, or long-lived in-memory state — look at Compute Engine or GKE
  • You need extremely low, predictable cold-start latency for every request at any traffic level — minimum instances helps but adds cost
  • You need full control over the underlying VM/OS — use Compute Engine

Alternatives

AWS App Runner / AWS Fargate, Azure Container Apps, Google Kubernetes Engine (for more control)

Pricing concepts

Cloud Run bills for CPU, memory, and requests only while a container instance is actively handling requests (plus a small always-on allocation if you set a minimum instance count). Scaling to zero means you pay nothing when there’s no traffic. Cost is driven mainly by request volume, execution time, and how much CPU/memory each instance is configured with — always confirm current rates against Google Cloud’s pricing page.

Security

  • Services are private by default and require IAM permission to invoke unless explicitly made public
  • Use a dedicated service account with least-privilege IAM roles for each service, not the default compute service account
  • Store secrets in Secret Manager and mount them as environment variables or volumes, never bake them into the image
  • Use VPC connectors if the service needs to reach private resources like a Cloud SQL instance on a private IP

Setup guide

  1. Containerize the application (Dockerfile or let Cloud Build use Buildpacks)
  2. Push the image to Artifact Registry
  3. Deploy to Cloud Run, setting memory/CPU, concurrency, and min/max instances
  4. Grant the service’s identity only the IAM roles it actually needs
  5. Set up a custom domain and map it if this replaces an existing public endpoint

Best practices

  • Keep containers stateless; use Cloud Storage, Cloud SQL, or Memorystore for anything that must persist
  • Set a reasonable concurrency value — too high can overload a single instance, too low wastes capacity
  • Use minimum instances only where cold-start latency is genuinely a problem, since it adds baseline cost
  • Log to stdout/stderr and let Cloud Logging capture it rather than writing to local files

FAQ

Does Cloud Run support WebSockets?

Yes, with request timeout limits that apply to the connection duration — check current limits before relying on very long-lived connections.

Can Cloud Run access a database on a private VPC?

Yes, via a Serverless VPC Access connector, or directly for Cloud SQL using the Cloud SQL connector.

Last reviewed: 2026-09-20