Deploying Cloud Run & Cloud Functions

Google ACE ACE · Planning and implementing a cloud solution

By Abu Anns · Last updated 20 November 2026Exam version: ACE (exam guide live 30 June 2026)

Serverless on Google Cloud

Cloud Run and Cloud Functions are Google Cloud's serverless compute services: you deploy code or containers, and Google manages the infrastructure, scaling, and availability. Both scale automatically from zero to thousands of instances, and both bill only for the resources consumed while handling work. The difference is what you deploy and how it is triggered. Cloud Run deploys a container that serves HTTP requests — a web service, an API, a website. Cloud Functions deploys a function — a single unit of code — that runs in response to an event, such as a file upload, a Pub/Sub message, or an HTTP request. Cloud Functions (2nd generation) runs on Cloud Run infrastructure under the hood, which is why the two services share features such as concurrency settings and VPC connectivity.

Deploying to Cloud Run

A Cloud Run deployment starts with a container image stored in Artifact Registry. You deploy it with gcloud run deploy, giving the service a name, the image, and the region — or you can deploy from source code, and Google builds the container for you with buildpacks. Each deployment creates a new revision: an immutable snapshot of the service's code and configuration. Revisions are the key to safe releases: you can split traffic between revisions (for example, 90% to the old revision and 10% to the new one), roll back instantly by shifting traffic to an earlier revision, and pin a revision for testing with a unique URL. The service gets a stable HTTPS URL, and by default it requires authentication — you must explicitly allow unauthenticated access (the run.invoker role for allUsers) if the service should be public.

Cloud Run's scaling settings matter for the exam. Each container instance handles requests with a configurable concurrency (default 80 requests per instance, up to 1,000), and the platform adds instances as traffic grows. Minimum instances keeps a number of instances warm to avoid cold starts, at a cost; maximum instances caps scaling to control cost or protect a downstream database from too many connections. A request can run for at most 60 minutes, and each instance can be given up to 32 GiB of memory and 8 vCPUs. CPU is allocated only while handling requests by default (which is why idle services cost almost nothing), but CPU always allocated is available for workloads that do background work between requests.

Deploying Cloud Functions

A Cloud Function is deployed with gcloud functions deploy, specifying the runtime (such as Python, Node.js, or Go), the entry point (the function to call), and the trigger. The trigger is what makes functions useful: an HTTP trigger turns the function into a small web endpoint, while an event trigger runs it when something happens elsewhere in Google Cloud. Common event sources are Cloud Storage (an object is created, deleted, or archived in a bucket), Pub/Sub (a message arrives on a topic), Firestore (a document is created or changed), and Eventarc, which routes events from many Google Cloud sources (and from custom sources) to Cloud Run or Cloud Functions targets.

Functions are short-lived and stateless: each invocation runs in a fresh environment, and any local state is discarded afterward. The maximum timeout for a 2nd generation function is 60 minutes (9 minutes for 1st generation), and memory can be configured up to 16 GiB. Because invocations can occasionally be retried, functions should be written idempotently — running the same event twice should produce the same result, not a duplicate side effect. That design point appears in exam questions about event-driven architectures: the correct answer often involves idempotency or deduplication, not just the trigger choice.

Choosing where to deploy

The exam guide asks you to determine where to deploy an application using Cloud Run (fully managed), Cloud Run for Anthos (now GKE-based Cloud Run on Google Distributed Cloud — the on-premises and GKE variant), or Cloud Functions. For ACE purposes, the decision is:

WorkloadDeploy to
Containerized web service or API, public or internalCloud Run (fully managed)
Short code triggered by an event (Storage, Pub/Sub, Firestore)Cloud Functions
Containerized service that must run on your own GKE cluster or on-premisesCloud Run on GKE / Anthos variant
Long-running background processing beyond the request timeoutNot serverless — consider Compute Engine, GKE, or Cloud Run jobs

One more member of the family is worth knowing: Cloud Run jobs run containers to completion (rather than serving requests), which suits batch tasks — a nightly report generator, a data-processing job — that should run once and stop. Jobs share Cloud Run's serverless scaling and billing, and they can be scheduled with Cloud Scheduler. If a question describes a containerized task that runs on a schedule and then exits, a Cloud Run job is a strong candidate.

Events: Pub/Sub, Storage notifications, and Eventarc

Event-driven design on Google Cloud usually involves Pub/Sub, the asynchronous messaging service: publishers send messages to a topic, and subscribers (including Cloud Functions and Cloud Run services) receive them. Pub/Sub decouples the producer from the consumer — the producer does not wait for processing, and messages are retained until acknowledged. Cloud Storage object change notifications can publish directly to a Pub/Sub topic when objects are created or deleted, which is how a file upload triggers processing. Eventarc is the newer, broader event router: it delivers events from Google Cloud services (including audit-log-based events) and custom sources to Cloud Run and other targets, with filtering and transformation. For the exam, the practical mapping is: a Storage event triggering a function is usually done directly or through Pub/Sub; a complex multi-source event flow points to Eventarc.

Security and connectivity for serverless

Serverless services still need network and identity configuration, and the exam tests the common patterns. Every Cloud Run service and Cloud Function runs as a service account: by default it is the project's default Compute Engine service account, but best practice is a dedicated service account with only the roles the service needs — for example, a function that writes to one Firestore collection should not carry a project-wide Editor role. Ingress settings control who can reach a Cloud Run service: allow all traffic (public), allow only internal traffic (from within the VPC or from other Google Cloud services), or allow only traffic from a load balancer. The internal-only setting is the answer when a service should be reachable only by other services in the same project or VPC.

For outbound connectivity, Cloud Run services and functions run outside your VPC by default, so reaching a private resource — a Cloud SQL instance with only a private IP, or a VM in your VPC — requires a VPC connector (a Serverless VPC Access connector) that bridges the serverless environment into the VPC. The connector is a small piece of infrastructure with its own subnet and scaling settings, and it is the standard answer to "my Cloud Run service cannot reach my private database". The exam pairing is worth memorizing: private database plus serverless service equals VPC connector. Without it, the serverless service can only reach public endpoints.

Advertisement

Exam traps to watch for

Practice questions

Test yourself on this guide. Answers are checked instantly, with a full explanation for each question.

Q1.A developer deploys a Cloud Run service and shares its URL with a customer, but the customer gets a 403 Forbidden error. The service works when the developer tests it. What is the most likely cause?

Report an error

Q2.A team wants to deploy a new version of a Cloud Run service to 10% of users first, and roll back instantly if errors appear. How should they do this?

Report an error

Q3.A company wants a thumbnail generated automatically whenever a user uploads a photo to a Cloud Storage bucket. Which is the simplest design?

Report an error

Q4.An order-processing system publishes a message to Pub/Sub for each new order. A function processes each message and charges the customer. Occasionally a message is delivered twice. What property must the function have to avoid double-charging?

Report an error

Q5.A team needs to run a containerized report generator once a night. It runs for 20 minutes and then exits. Which service is the best fit?

Report an error

Q6.A Cloud Run service connects to a Cloud SQL database that allows at most 100 simultaneous connections. During traffic spikes, the service scales up and the database starts rejecting connections. What should you configure?

Report an error

Q7.A company wants to route events from several Google Cloud services — including audit log events — to a Cloud Run service, with filtering on event type. Which service should they use to route the events?

Report an error

Q8.A developer wants to deploy a Python function that runs when a message arrives on a Pub/Sub topic. Which command deploys it?

Report an error