Skip to content

Professional Cloud Developer · Domain 1: Designing highly scalable, secure, and reliable cloud-native applications · 32% of the exam

Task 1.1: Designing high-performing applications and APIs.

Choosing among Compute Engine, GKE and Cloud Run, shaping containers for Cloud Run and GKE, regional and zonal services, load balancers and session affinity, caching with Memorystore, REST and gRPC APIs behind Apigee or API Gateway, event-driven integration with Eventarc and Pub/Sub, resource sizing and cost, replication for failover, traffic splitting, and orchestration with Workflows, Cloud Tasks and Cloud Scheduler.

Study it

Sample questions

Try each one before opening the answer. Every option is explained, with the Google Cloud documentation page that proves it.

Question 1 · choose 1

A team is containerizing a message broker for industrial sensors. The sensors in several factories connect to the broker over the internet with a plain MQTT client over raw TCP on port 1883, and their firmware can't be changed to use HTTP, WebSockets or gRPC. The broker writes each client session to a local persistent disk so that sessions survive a restart of the broker process. Which platform fits this container?

  1. AGKE, running the broker as a workload that keeps its sessions on a persistent volume
  2. BA Cloud Run worker pool, which needs no HTTP listener, with a Cloud Storage volume mount that holds the session files
  3. CA Cloud Run service with a Cloud Storage volume mount that holds the session files
  4. DA Cloud Run functions function with an event trigger for the incoming sensor connections
Show the answer and why
  • AGKE, running the broker as a workload that keeps its sessions on a persistent volume

    Correct

    The broker meets neither Cloud Run service criterion it would need (requests over HTTP, HTTP/2, WebSockets or gRPC, and no local persistent file system), and the Cloud Run page points such apps to GKE.

  • BA Cloud Run worker pool, which needs no HTTP listener, with a Cloud Storage volume mount that holds the session files

    Incorrect

    Worker pools have no public endpoint, so sensors that connect over the internet would have nothing to reach.

  • CA Cloud Run service with a Cloud Storage volume mount that holds the session files

    Incorrect

    The mount answers the file system need, but the service still has to be reached over HTTP, HTTP/2, WebSockets or gRPC.

  • DA Cloud Run functions function with an event trigger for the incoming sensor connections

    Incorrect

    A function is invoked by requests or events, not by long-lived raw TCP connections from devices.

A Cloud Run service is a good fit only if the app serves requests, streams or events over HTTP, HTTP/2, WebSockets or gRPC (or runs to completion) and needs no local persistent file system; otherwise the page suggests GKE. A Cloud Run worker pool doesn't need to listen for requests, but it has no public endpoint, so it suits pull-style background work, not a broker that devices on the internet connect to. On GKE the broker runs as a containerized workload with a persistent volume.

Question 2 · choose 1

A Cloud Run service collects click events and batches them in memory: events = [] def flush_loop(): while True: time.sleep(30) send_batch(events) events.clear() threading.Thread(target=flush_loop, daemon=True).start() @app.post("/track") def track(): events.append(request.get_json()) return "", 204 The service uses request-based billing and keeps one minimum instance. After quiet periods, analysts find that events received shortly before an instance went away were never sent. Which change makes sure buffered events are sent before an instance is shut down?

  1. AKeep the loop and rely on the minimum instance, which Cloud Run doesn't shut down
  2. BRaise the service's request timeout so that the loop gets time to finish a batch
  3. CInstall a SIGTERM handler that sends whatever is left in the buffer
  4. DMove the service to the first generation execution environment
Show the answer and why
  • AKeep the loop and rely on the minimum instance, which Cloud Run doesn't shut down

    Incorrect

    An idle instance can be shut down at any time, including one kept warm by the minimum instances setting.

  • BRaise the service's request timeout so that the loop gets time to finish a batch

    Incorrect

    The request timeout bounds how long a request may take; it doesn't delay the shutdown of an instance.

  • CInstall a SIGTERM handler that sends whatever is left in the buffer

    Correct

    Before shutting down an instance, Cloud Run sends SIGTERM and allows a 10-second period, with CPU allocated, before SIGKILL.

  • DMove the service to the first generation execution environment

    Incorrect

    In the first generation, an instance that doesn't trap SIGTERM is shut down at once; the move adds nothing that sends the buffer.

Cloud Run can shut down idle instances at any time, even those kept warm by minimum instances. Before it does, it sends SIGTERM to the containers, which starts a 10-second period during which the instance is allocated CPU; then it sends SIGKILL. A SIGTERM handler that sends the remaining events is the place to flush in-memory state. The request timeout and the execution environment don't give the application a chance to send the buffer.

Question 3 · choose 1

An online store runs its web front end and its API as two Cloud Run services in europe-west1. It wants both behind the single host name www.example.com, with requests for /api/* going to the API service and everything else to the front end, and it wants Cloud Armor rules in front of both. What should the team set up?

  1. AAn external passthrough Network Load Balancer with one serverless NEG for each service, both behind one external IP address
  2. BA global external Application Load Balancer, a serverless NEG per service, and a URL map routing /api/*
  3. CA regional internal Application Load Balancer with a serverless NEG for each service
  4. DCloud Run traffic tags on the front-end service, with one tag for each path prefix
Show the answer and why
  • AAn external passthrough Network Load Balancer with one serverless NEG for each service, both behind one external IP address

    Incorrect

    Serverless NEGs aren't supported by passthrough or proxy Network Load Balancers.

  • BA global external Application Load Balancer, a serverless NEG per service, and a URL map routing /api/*

    Correct

    Serverless NEGs put Cloud Run services behind an Application Load Balancer, whose URL map routes paths to backend services that can carry Cloud Armor policies.

  • CA regional internal Application Load Balancer with a serverless NEG for each service

    Incorrect

    An internal Application Load Balancer serves clients inside a VPC network, not shoppers on the internet.

  • DCloud Run traffic tags on the front-end service, with one tag for each path prefix

    Incorrect

    A tag gives a revision of one service its own URL; it doesn't route the paths of a host name to two services.

To put several Cloud Run services behind one external address and host name, use a global external Application Load Balancer with a serverless NEG for each service. The URL map routes requests by path to the backend services, and serverless backends can use the load balancer's features, such as Cloud Armor. Serverless NEGs aren't supported by Network Load Balancers, internal load balancers don't serve internet clients, and Cloud Run tags address revisions of one service.

Question 4 · choose 1

A Cloud Run service exposes a gRPC API whose clients use server streaming. The team turned on HTTP/2 end-to-end for the service and configured the gRPC server in the container to listen on $PORT with TLS, using a certificate copied into the image. Since that deployment, every call fails. Which configuration makes the streaming calls work?

  1. ATurn HTTP/2 end-to-end off and have the container serve plain HTTP/1.1 on $PORT
  2. BKeep HTTP/2 end-to-end and load a certificate from Certificate Manager into the container's TLS listener
  3. CKeep TLS in the container and raise the service's request timeout for long-lived streams
  4. DKeep HTTP/2 end-to-end and have the gRPC server accept cleartext HTTP/2 (h2c) on $PORT
Show the answer and why
  • ATurn HTTP/2 end-to-end off and have the container serve plain HTTP/1.1 on $PORT

    Incorrect

    Streaming gRPC needs the service configured to use HTTP/2, the transport that gRPC streaming relies on.

  • BKeep HTTP/2 end-to-end and load a certificate from Certificate Manager into the container's TLS listener

    Incorrect

    Cloud Run terminates TLS itself, so any TLS listener in the container, whatever its certificate, still fails.

  • CKeep TLS in the container and raise the service's request timeout for long-lived streams

    Incorrect

    The timeout doesn't touch the protocol mismatch between Cloud Run and the container's TLS listener.

  • DKeep HTTP/2 end-to-end and have the gRPC server accept cleartext HTTP/2 (h2c) on $PORT

    Correct

    Streaming gRPC needs HTTP/2, and with HTTP/2 end-to-end the container must handle cleartext HTTP/2 because Cloud Run terminates TLS.

Two documented rules decide this. The gRPC page says to configure the service to use HTTP/2 for streaming gRPC, because HTTP/2 is the transport of gRPC streaming. The container contract says that TLS is terminated by Cloud Run and that, with HTTP/2 end-to-end, the container must handle requests in HTTP/2 cleartext (h2c) format. So the service keeps HTTP/2 end-to-end and the server listens for h2c on $PORT without TLS.

Question 5 · choose 1

A Cloud Run service receives Cloud Storage object-finalized events through an Eventarc trigger and creates an invoice for each uploaded order file. Finance found a few invoices created twice for the same upload. Customers sometimes upload a corrected file under the same object name, and each such upload must produce a new invoice. Which change stops the duplicates without losing those invoices?

  1. ASkip an event when an invoice already exists for the event's object name
  2. BAnswer with HTTP 200 only after the invoice is stored, so that no event is ever delivered again
  3. CRecord the source and ID of each event and skip any event whose pair was already processed
  4. DMove the trigger to the Cloud Audit Logs event for object creation
Show the answer and why
  • ASkip an event when an invoice already exists for the event's object name

    Incorrect

    A corrected file reuses the object name, so its new invoice would be skipped.

  • BAnswer with HTTP 200 only after the invoice is stored, so that no event is ever delivered again

    Incorrect

    Delivery is at least once, so a handler can receive duplicate events whatever it answers.

  • CRecord the source and ID of each event and skip any event whose pair was already processed

    Correct

    Duplicate deliveries carry the same source and ID, while a new upload creates a new event with its own ID.

  • DMove the trigger to the Cloud Audit Logs event for object creation

    Incorrect

    Eventarc's at-least-once delivery applies to that trigger too, so duplicates remain.

Eventarc delivers events at least once, so a handler might receive duplicate events and should be idempotent. Under the CloudEvents specification, the combination of the source and id attributes is unique, and events with the same combination are duplicates; the event ID also works as an idempotency key. Deduplicating on the object name would drop the invoices of corrected uploads, which arrive as new events.

Question 6 · choose 1

A thumbnail service on Cloud Run shares one in-memory cache among 16 concurrent requests per instance and uses request-based billing. Its deployment is rejected with this revision template: spec: template: spec: containerConcurrency: 16 containers: - image: europe-docker.pkg.dev/acme/apps/thumbs:2.3 resources: limits: cpu: 500m memory: 512Mi Which change makes the revision deployable while each instance still takes 16 concurrent requests?

  1. ASwitch the service to instance-based billing and keep the other values
  2. BRaise the memory limit to 1Gi and keep the CPU limit at 500m
  3. CSet containerConcurrency to 1 and raise the maximum number of instances
  4. DSet the CPU limit to 1 and keep containerConcurrency at 16
Show the answer and why
  • ASwitch the service to instance-based billing and keep the other values

    Incorrect

    Below 1 vCPU, billing must be request-based and concurrency must be 1, so this breaks one more rule.

  • BRaise the memory limit to 1Gi and keep the CPU limit at 500m

    Incorrect

    Below 1 vCPU, maximum concurrency must be 1, whatever the memory limit.

  • CSet containerConcurrency to 1 and raise the maximum number of instances

    Incorrect

    That deploys, but each instance then serves one request at a time instead of 16.

  • DSet the CPU limit to 1 and keep containerConcurrency at 16

    Correct

    The concurrency rule applies only below 1 vCPU, and 1 vCPU allows up to 4 GiB of memory.

Cloud Run allows CPU limits below 1 vCPU, but then enforces extra requirements: maximum concurrency must be 1, billing must be request-based, the first generation execution environment must be used, and memory above 512 MiB needs at least 0.5 vCPU. A revision with 0.5 vCPU and a concurrency of 16 breaks the concurrency rule. With a CPU limit of 1, a concurrency of 16 and 512 MiB of memory are allowed.

Question 7 · choose 1

During an incident on Monday, an engineer rolled the Cloud Run service checkout back by sending all of its traffic to the earlier revision checkout-00041-kaz in the Google Cloud console. Since then, every merge runs this Cloud Build step, and each build succeeds and creates a new revision: - name: gcr.io/google.com/cloudsdktool/cloud-sdk entrypoint: gcloud args: ['run', 'deploy', 'checkout', '--image', '${_IMAGE}:${_TAG}', '--region', 'europe-west1'] Users still get the code of checkout-00041-kaz. What should the team do so that new deployments receive traffic again?

  1. ARun gcloud run services update-traffic checkout --to-latest once
  2. BAdd --no-traffic to the deploy step so that the build controls traffic
  3. CRun the build again for the latest commit to create a fresh revision
  4. DGrant the build's service account Cloud Run Admin so its deploys can move traffic
Show the answer and why
  • ARun gcloud run services update-traffic checkout --to-latest once

    Correct

    Assigning traffic to a previous revision sticks for later deployments until all traffic is sent to the latest revision.

  • BAdd --no-traffic to the deploy step so that the build controls traffic

    Incorrect

    A --no-traffic deployment creates a revision that serves no traffic, the opposite of what is needed.

  • CRun the build again for the latest commit to create a fresh revision

    Incorrect

    Another revision changes nothing while the traffic assignment still points at checkout-00041-kaz.

  • DGrant the build's service account Cloud Run Admin so its deploys can move traffic

    Incorrect

    The deploys already succeed and create revisions; the traffic assignment, not a permission, keeps users on the old revision.

When traffic is assigned to a previous revision or split between revisions, all subsequent deployments use that traffic pattern. A rollback that sends 100% to checkout-00041-kaz therefore keeps users there while new revisions pile up. Sending all traffic to the latest revision, for example with gcloud run services update-traffic SERVICE --to-latest, makes this revision and future ones serve the traffic again.

Question 8 · choose 1

A team wants to containerize an in-memory analytics engine that serves HTTP queries and needs 48 GiB of memory in each instance to hold its working set. Which platform can run it as is?

  1. AA Cloud Run service with the largest CPU limit it offers
  2. BA Cloud Run service with concurrency set to 1
  3. CA Cloud Run service with startup CPU boost turned on
  4. DGKE, with Pods that request the memory the engine needs
Show the answer and why
  • AA Cloud Run service with the largest CPU limit it offers

    Incorrect

    A Cloud Run instance is a good fit only up to 8 CPU and 32 GiB of memory.

  • BA Cloud Run service with concurrency set to 1

    Incorrect

    Concurrency doesn't change the 32 GiB memory ceiling of an instance.

  • CA Cloud Run service with startup CPU boost turned on

    Incorrect

    CPU boost adds CPU during startup; memory per instance still stops at 32 GiB.

  • DGKE, with Pods that request the memory the engine needs

    Correct

    Apps that need more than 8 CPU or 32 GiB per instance aren't a fit for Cloud Run, which points to GKE.

One criterion for a Cloud Run service is that the app doesn't require more than 8 CPU and 32 GiB of memory per instance. An app that misses a criterion can run on GKE, where Pods request the resources they need.

Question 9 · choose 1

A Cloud Run service sends 90% of traffic to revision v1 and 10% to a new revision v2. Session affinity is enabled on v2 only. Without anyone changing the split, the share of requests that v2 serves keeps growing. Why?

  1. ARequests shift toward the revision with session affinity, because affinity takes precedence over the traffic split
  2. BCloud Run moves traffic to the newest revision once it has run for a day
  3. CSession affinity makes v2's instances handle only one client each, so more of them start
  4. DThe load balancer in front of the service applies its own affinity to v2
Show the answer and why
  • ARequests shift toward the revision with session affinity, because affinity takes precedence over the traffic split

    Correct

    Requests without an affinity cookie are split at random, and those that land on v2 stay there.

  • BCloud Run moves traffic to the newest revision once it has run for a day

    Incorrect

    The page traces the shift to session affinity; it describes no automatic move of traffic to the newest revision.

  • CSession affinity makes v2's instances handle only one client each, so more of them start

    Incorrect

    An instance with session affinity still receives requests from different clients.

  • DThe load balancer in front of the service applies its own affinity to v2

    Incorrect

    Cloud Run's session affinity is independent of any load balancer affinity.

Session affinity is enabled per revision, and it takes precedence over traffic splitting. When only some revisions have affinity, requests without an affinity cookie are split at random, and those assigned to a revision with affinity keep going there, so traffic gradually moves toward those revisions without any change to the split.

Question 10 · choose 1

A team deploys a Cloud Run service with a CPU limit of 8 vCPU and a memory limit of 2 GiB. The deployment is rejected. Which change makes it valid while keeping 8 vCPU?

  1. ASwitch the service to instance-based billing
  2. BRaise the memory limit to at least 4 GiB
  3. CTurn on startup CPU boost for the revision
  4. DLower the maximum concurrency to 1
Show the answer and why
  • ASwitch the service to instance-based billing

    Incorrect

    Billing doesn't change the memory that 8 vCPU require.

  • BRaise the memory limit to at least 4 GiB

    Correct

    8 vCPU need between 4 and 32 GiB of memory.

  • CTurn on startup CPU boost for the revision

    Incorrect

    Startup CPU boost adds CPU during startup; it doesn't change the memory rule.

  • DLower the maximum concurrency to 1

    Incorrect

    Concurrency has no bearing on the memory range for 8 vCPU.

Cloud Run ties memory to the CPU limit: for example, 4 vCPU need 2 to 16 GiB, and 8 vCPU need 4 to 32 GiB. A service with 8 vCPU must have at least 4 GiB of memory.

Practice domain 1 →Practice all domains →