Google Cloud Run

Google Cloud Run is a serverless container platform: you deploy a container image and Cloud Run runs it with automatic scaling, including scaling to zero when idle. It's the sweet spot when you want serverless operations but the packaging model of containers — no Kubernetes to manage, but full control over your runtime and dependencies.

You pay per request and compute time, and the platform handles routing, scaling, and infrastructure. The design discipline is the usual serverless one: stateless request handling, with all state pushed to managed databases, caches, or object storage.

TL;DR

Quick Example

Deploy straight from source — Cloud Run builds the container for you:

How Cloud Run Works

  1. You build a container image (or deploy from source).
  2. Deploy it as a service.
  3. Cloud Run routes HTTP requests to instances.
  4. Instances scale up and down automatically (to zero when idle).

The knobs you'll tune:

Common Use Cases

Best Practices

Common Mistakes

Relying on the local filesystem

Running long jobs inside a request

FAQ

How is Cloud Run different from Cloud Functions?

Cloud Run deploys any container image and handles full HTTP services with your choice of language, runtime, and dependencies. Cloud Functions runs individual function snippets in supported runtimes, ideal for small event handlers. Cloud Run gives more control and portability (it's just a container); Functions is simpler for tiny event-driven logic. For most APIs, Cloud Run is the more flexible default.

What concurrency setting should I use?

Cloud Run can send multiple concurrent requests to one instance (default up to 80), unlike Lambda's one-request-per-instance model. Higher concurrency improves efficiency and cost for I/O-bound services, but set it lower for CPU-heavy or memory-hungry workloads so instances aren't overwhelmed. Load-test to find the right value.

How do I reduce cold starts?

Set min instances above zero to keep a warm pool for latency-sensitive endpoints (this adds baseline cost). Also shrink your image, minimize startup work (lazy-load heavy dependencies), and keep the container's boot fast. For bursty but tolerant workloads, scaling from zero is fine and cheapest.

Can Cloud Run run background workers, not just HTTP services?

It's primarily request-driven, but you can run background-style work triggered by HTTP/Pub/Sub push, and Cloud Run Jobs exist for run-to-completion tasks. For long-running or queue-consuming workers, pair Cloud Run with Pub/Sub or Cloud Tasks rather than holding work inside a single request.

Related Topics

References