Professional Cloud Developer Free Practice Questions — Page 2
Question 5
You are deploying a Python application to Cloud Run using Cloud Source Repositories and Cloud Build. The Cloud Build pipeline is shown below:
You want to optimize deployment times and avoid unnecessary steps. What should you do?
A. Remove the step that pushes the container to Artifact Registry.
B. Deploy a new Docker registry in a VPC, and use Cloud Build worker pools inside the VPC to run the build pipeline.
C. Store image artifacts in a Cloud Storage bucket in the same region as the Cloud Run instance.
D. Add the --cache-from argument to the Docker build step in your build config file.
Show Answer
Correct Answer: D
Explanation: Add `--cache-from` to the Docker build step and use a previously built image as the cache source. Docker can reuse unchanged layers instead of rebuilding them, reducing build time. The image still needs to be pushed to Artifact Registry for Cloud Run to deploy it; the other options add complexity or do not provide a suitable image registry.
Question 6
You are trying to connect to your Google Kubernetes Engine (GKE) cluster using kubectl from Cloud Shell. You have deployed your GKE cluster with a public endpoint. From Cloud Shell, you run the following command:
You notice that the kubectl commands time out without returning an error message. What is the most likely cause of this issue?
A. Your user account does not have privileges to interact with the cluster using kubectl.
B. Your Cloud Shell external IP address is not part of the authorized networks of the cluster.
C. The Cloud Shell is not part of the same VPC as the GKE cluster.
D. A VPC firewall is blocking access to the cluster’s endpoint.
Show Answer
Correct Answer: B
Explanation: The cluster’s public endpoint may still be restricted to authorized networks. If Cloud Shell’s external IP is not on that allowlist, kubectl can time out while trying to reach the endpoint. Permission issues would typically return an authorization error, and Cloud Shell need not be in the cluster’s VPC.
Question 6
Your company is planning a global event. You need to configure an event registration portal for the event. You have decided to deploy the registration service by using Cloud Run. Your company’s marketing team does not want to advertise the Cloud Run service URL. They want the registration portal to be accessed by using a personalized hostname or path in your custom domain URL pattern, for example,
A. Configure Cloud Armor to block traffic on the Cloud Run service URL and allow reroutes from only the custom domain URL pattern.
B. Set up an HAProxy on Compute Engine, and add routing rules for a custom domain to the Cloud Run service URL.
C. Add a global external Application Load Balancer in front of the service, and configure a DNS record that points to the load balancer’s IP address.
D. Create a CNAME record that points to the Cloud Run service URL.
Show Answer
Correct Answer: C
Explanation: A global external Application Load Balancer is the recommended way to expose Cloud Run under a custom domain with advanced routing (hostnames and paths), TLS termination, and a static IP. You then point your DNS record to the load balancer's IP address. A CNAME directly to the Cloud Run URL is not the recommended approach for custom routing patterns, Cloud Armor alone does not provide hostname/path remapping, and managing HAProxy on Compute Engine is unnecessary for this use case.
Question 7
This architectural diagram depicts a system that streams data from thousands of devices. You want to ingest data into a pipeline, store the data, and analyze the data using SQL statements. Which Google Cloud services should you use for steps 1, 2, 3, and 4?
A. 1. App Engine 2. Pub/Sub 3. BigQuery 4. Firestore
B. 1. Dataflow 2. Pub/Sub 3. Firestore 4. BigQuery
C. 1. Pub/Sub 2. Dataflow 3. BigQuery 4. Firestore
D. 1. Pub/Sub 2. Dataflow 3. Firestore 4. BigQuery
Show Answer
Correct Answer: D
Explanation: Use Pub/Sub to ingest device data, Dataflow to process it in the pipeline, Firestore as the transaction database, and BigQuery to analyze the data with SQL.
Question 7
You are tasked with using C++ to build and deploy a microservice for an application hosted on Google Cloud. The code needs to be containerized and use several custom software libraries that your team has built. You want to minimize maintenance of the application’s underlying infrastructure. How should you deploy the microservice?
A. Use Cloud Run functions to deploy the microservice.
B. Use Cloud Build to create the container, and deploy it on Cloud Run.
C. Use Cloud Shell to containerize your microservice, and deploy it on GKE Standard.
D. Use Cloud Shell to containerize your microservice, and deploy it on a Container-Optimized OS Compute Engine instance.
Show Answer
Correct Answer: B
Explanation: Cloud Run is a fully managed serverless platform for deploying containerized applications, including C++ services with custom libraries. Cloud Build can build the container image and integrate with Artifact Registry, after which deploying to Cloud Run minimizes infrastructure management. Cloud Run functions are intended for function workloads rather than arbitrary containerized microservices, while GKE Standard and Compute Engine require more infrastructure maintenance.
Question 8
Your team developed a web-based game that has many simultaneous players. Recently, users have started to complain that the leaderboard tallies the top scores too slowly. You investigated the issue and discovered that the application stack is currently using Cloud SQL for PostgreSQL. You want to improve the leaderboard performance as much as possible to provide a better user experience. What should you do?
A. Re-implement the leaderboard data to be stored in Memorystore for Redis.
B. Optimize the SQL queries to minimize slow-running queries.
C. Migrate the database and store the data in AlloyDB.
D. Update Cloud SQL for PostgreSQL to the latest version.
Show Answer
Correct Answer: A
Explanation: A real-time leaderboard with many concurrent reads and writes benefits from an in-memory data store. Memorystore for Redis provides very low-latency operations and supports data structures such as sorted sets that are well suited for maintaining ranked leaderboards. Query optimization, upgrading PostgreSQL, or migrating to AlloyDB may improve database performance, but they are less effective than using Redis for this specific access pattern.
Question 8
Your team is developing an application in Google Cloud that executes with user identities maintained by Cloud Identity. Each of your application's users will have an associated Pub/Sub topic to which messages are published, and a Pub/Sub subscription where the same user will retrieve published messages. You need to ensure that only authorized users can publish and subscribe to their own specific Pub/Sub topic and subscription. What should you do?
A. Bind the user identity to the pubsub.publisher and pubsub.subscriber roles at the resource level.
B. Grant the user identity the pubsub.publisher and pubsub.subscriber roles at the project level.
C. Grant the user identity a custom role that contains the pubsub.topics.create and pubsub.subscriptions.create permissions.
D. Configure the application to run as a service account that has the pubsub.publisher and pubsub.subscriber roles.
Show Answer
Correct Answer: A
Explanation: Grant each user the Pub/Sub Publisher role on their own topic and the Pub/Sub Subscriber role on their own subscription. Resource-level bindings restrict access to those specific resources.
Question 9
You are developing a custom job scheduler that must have a persistent cache containing entries of all Compute Engine VMs that are in a running state (not deleted, stopped, or suspended). The job scheduler checks this cache and only sends jobs to the available Compute Engine VMs in the cache. You need to ensure that the available Compute Engine instance cache is not stale. What should you do?
A. Set up an organization-level Cloud Storage log sink with a filter to capture the audit log events for Compute Engine. Configure an Eventarc trigger that executes when the Cloud Storage bucket is updated and sends these events to the application to update the cache.
B. Set up a Cloud Asset Inventory real-time feed of insert and delete events with the asset types filter set to compute.googleapis.com/Instance. Configure an Eventarc trigger that sends these events to the application to update the cache.
C. Set up an organization-level Pub/Sub log sink with a filter to capture the audit log events for Compute Engine. Configure an Eventarc trigger that sends these events to the application to update the cache.
D. Set up an organization-level BigQuery log sink. Configure the application to query this BigQuery table every minute to retrieve the last minute’s events and update the cache.
Show Answer
Correct Answer: C
Explanation: Use an event-driven pipeline based on Cloud Audit Logs exported to Pub/Sub. Compute Engine instance lifecycle and state-change audit events can be filtered and delivered with low latency, and Eventarc can trigger the cache update service so the scheduler's persistent cache stays current. Cloud Storage and BigQuery sinks add unnecessary latency, while a Cloud Asset Inventory feed of only insert/delete events would miss important running-state transitions such as stop, start, and suspend.
Question 9
You have an application running in App Engine. Your application is instrumented with Stackdriver Trace. The /product-details request reports details about four known unique products at /sku-details as shown below. You want to reduce the time it takes for the request to complete.
What should you do?
A. Increase the size of the instance class.
B. Change the Persistent Disk type to SSD.
C. Change /product-details to perform the requests in parallel.
D. Store the /sku-details information in a database, and replace the webservice call with a database query.
Show Answer
Correct Answer: C
Explanation: The trace shows four /sku-details calls taking about 30 ms each and running sequentially within /product-details. Run the calls in parallel so their latency overlaps, reducing the total request time.
Question 10
Your teammate has asked you to review the code below, which is adding a credit to an account balance in Cloud Datastore.
Which improvement should you suggest your teammate make?
A. Get the entity with an ancestor query.
B. Get and put the entity in a transaction.
C. Use a strongly consistent transactional database.
D. Don't return the account entity from the function.
Show Answer
Correct Answer: B
Explanation: The balance is read, incremented, and written back. Without a transaction, concurrent credits can both read the same old balance and overwrite one another, losing an update. Perform the get and put in a transaction so the update is applied atomically.
$19
Get all 358 questions with detailed answers and explanations
Instant download HTML + PDF delivered the moment payment clears.
Secure Stripe checkout we never see or store your card details.
7-day refund if files are defective see our refund policy.