All Google Cloud exams

Free Professional Cloud Developer practice test: 30 questions with answers

30 original questions for Professional Cloud Developer, drawn from every topic area. Answer each one to see whether you got it right and why. No sign-up.

Free questions
30
Full bank
112 questions
Real exam
120 min

Professional Cloud Developer exam guide: topics, cost and format

All 30 Professional Cloud Developer questions with answers

The same questions as the test above, grouped by exam topic. Open any question to see the answer and explanation.

Integrating Google Cloud services (8 questions)

  1. Question 1

    A Cloud Run service must read a database password at runtime. The password must be rotatable without rebuilding the image, and the service account should have no access to other secrets. Which configuration is best?

    1. AStore the password in Secret Manager and grant the service account access to that secret only
    2. BBake the password into the container image as an environment variable and rebuild at each rotation
    3. CStore the password in a plain text file in the bucket that serves the site's static assets
    4. DGrant the service account the Project Owner role so it can read any secret created later
    Show answer and explanation
    Correct answer: A

    Secret Manager supports new versions without a rebuild, and per-secret IAM keeps the service account narrowly scoped. Baking secrets into images forces rebuilds and exposes the value in image layers. A public static bucket is not a secret store, and Owner grants far more access than the service needs.

  2. Question 2

    A backend on Compute Engine calls Google Cloud APIs with a service account. The developer must avoid creating and storing long-lived key files. Which approach should the developer use?

    1. ACreate an API key on the Credentials page and pass it as a query parameter on each request
    2. BAttach the service account to the VM so the client libraries get credentials from the metadata server
    3. CSet the developer's personal Google credentials in an environment variable on the VM
    4. DCreate a JSON key for the service account, embed it in the source, and rotate it quarterly
    Show answer and explanation
    Correct answer: C

    When a service account is attached to a Compute Engine VM, Application Default Credentials fetch short-lived tokens from the metadata server, so no key file is needed. Embedding a JSON key creates a long-lived secret to protect. API keys do not identify a workload with IAM permissions, and personal credentials should never be used by a service.

  3. Question 3

    An application publishes events to Pub/Sub, and a Cloud Function processes them. Some events fail during a downstream outage and must be retried later without blocking newer events. Which configuration is most appropriate?

    1. ASet message retention to one hour and restart the Cloud Function manually when the outage ends
    2. BPublish each event twice so that one copy survives the outage without any retry configuration
    3. CAdd a retry policy and a dead-letter topic to the subscription
    4. DReplace Pub/Sub with a Cloud Scheduler job that polls the source database each minute for new rows
    Show answer and explanation
    Correct answer: C

    A retry policy with backoff and a dead-letter topic lets failed messages retry and then be set aside after a limit, so newer messages are not blocked. Short retention and manual restarts depend on people, not on the system. Publishing duplicates does not give reliable recovery, and polling a database adds load and latency.

  4. Question 4

    A service writes uploaded files to Cloud Storage and must notify another service when each upload completes, without polling. Which design is best?

    1. ARun a cron job on a VM that lists the bucket each minute and compares the result with the last run
    2. BConfigure a Cloud Storage notification that publishes object finalize events to a Pub/Sub topic
    3. CHave the uploading client call the other service directly with the object name after the upload returns
    4. DEnable object versioning on the bucket and have the second service read the version history every hour
    Show answer and explanation
    Correct answer: B

    Cloud Storage can publish OBJECT_FINALIZE notifications to Pub/Sub, which decouples the services and avoids polling. Listing the bucket on a schedule is polling and scales poorly. A direct call from the client can fail silently, and versioning records history without announcing completion.

  5. Question 5

    A Cloud Function must write generated reports to one Cloud Storage bucket and nothing else. Which role should be granted to the function's service account?

    1. AGrant the Storage Admin role on the project so the function can manage buckets and objects
    2. BGrant the storage.objectCreator role on the destination bucket only, not on the project
    3. CGrant the Editor basic role on the project so the function can write to any resource it might need
    4. DGrant the default service account the Owner role on the destination bucket to avoid permission errors
    Show answer and explanation
    Correct answer: B

    The objectCreator role on the single destination bucket grants only permission to write objects, which matches the requirement. Storage Admin and Editor grant far broader access than writing one bucket needs. Owner on the bucket also allows deleting objects and changing permissions, which is more than required.

  6. Question 6

    A microservice in one project must call a Cloud Run service in another project. The caller must authenticate with a service account, and the callee must not be publicly accessible. Which configuration is correct?

    1. AMake the callee public with allUsers as Invoker and check the caller's IP address in application code
    2. BPut both services in one VPC and rely on private IP access without any IAM binding
    3. CShare the callee project's owner credentials with the caller through an environment variable
    4. DGrant the caller's service account the Cloud Run Invoker role on the callee and send an ID token for the callee URL
    Show answer and explanation
    Correct answer: B

    The Cloud Run Invoker role on the callee lets only the caller's service account invoke it, and the caller presents an ID token for the callee's audience. Public access with IP checks is weak, and sharing owner credentials is unsafe. A VPC alone does not authorize requests, because Cloud Run still checks IAM.

  7. Question 7

    A backend service calls several Google Cloud APIs and must keep its credentials out of source code and logs. Which two practices should the team adopt? (Choose two.)

    1. ARetrieve secrets at runtime from Secret Manager, using a service account with access to only the secrets it needs
    2. BPrint the full request headers, including the authorization token, to Cloud Logging to aid debugging
    3. CStore the service account JSON key in the Git repository under a directory named config for convenience
    4. DUse Application Default Credentials on the hosting platform instead of long-lived key files where possible
    5. ECommit an encrypted copy of the key and share the decryption password in the team chat channel
    Show answer and explanation
    Correct answer: A, D

    Secret Manager with narrowly scoped access keeps secrets out of code and logs, and Application Default Credentials avoid long-lived key files on managed platforms. Logging authorization headers and committing keys leak secrets, and an encrypted key with its password shared in chat is still exposed. These are the mistakes the question is testing for.

  8. Question 8

    A streaming consumer reads from a Pub/Sub subscription, and the backlog grows during traffic bursts. Which two changes most directly help the consumer keep up? (Choose two.)

    1. AAdd consumer instances that pull from the same subscription so messages are shared across them
    2. BShorten the message retention period on the subscription to ten minutes
    3. CIncrease the acknowledgement deadline on the subscription to the maximum value of 600 seconds
    4. DLet the consumer scale out automatically, for example on Cloud Run or GKE, based on the backlog
    5. EEnable message ordering on the topic so that consumers process one message at a time
    Show answer and explanation
    Correct answer: A, D

    Several pull consumers on one subscription share the work, and autoscaling those consumers on backlog adds throughput as the queue grows. Shorter retention can lose messages, and a longer acknowledgement deadline does not add capacity. Ordering serialises processing, which reduces throughput rather than increasing it.

Deploying applications (8 questions)

  1. Question 9

    A team deploys a Cloud Run service with a new revision and wants 10 percent of traffic to go to it while the rest stays on the current revision, with a quick rollback path. Which approach is correct?

    1. ADeploy with the no-traffic flag, then use update-traffic to send the revision 10 percent
    2. BDeploy with a minimum of ten instances so the revision receives requests in proportion to its size
    3. CDeploy with a ten-second request timeout so slow requests fall back to the previous revision automatically
    4. DDeploy as a separate service and add a DNS record weighted at 10 percent for its hostname
    Show answer and explanation
    Correct answer: A

    Deploying with --no-traffic keeps the new revision out of rotation, and update-traffic then assigns it a 10 percent share while the old revision keeps the rest. Rolling back is a single traffic change to the old revision. Instance counts do not divide traffic, and a timeout does not route requests to a fallback revision.

  2. Question 10

    A production service must run the exact container image that passed the tests, not whatever a mutable tag points to at deploy time. Which practice best supports this?

    1. ATag the image as latest in Artifact Registry and deploy whichever image carries that tag
    2. BRecord the image digest after the build and deploy using that digest reference
    3. CEnable automatic vulnerability scanning so deployments use only images with no open findings
    4. DRebuild the image during the deploy step using the newest base image so that patches are included
    Show answer and explanation
    Correct answer: B

    A digest identifies the exact image content, so deploying by digest guarantees the tested artifact is the one that runs. Rebuilding during deploy can produce different bytes from the tested build. A mutable latest tag can move after testing, and vulnerability scanning reduces risk but does not pin content.

  3. Question 11

    A Compute Engine application runs on many VMs. Configuration changes must be rolled out gradually across the fleet, and the rollout must stop if health checks fail. Which mechanism is most appropriate?

    1. AA single large VM with the application deployed by hand over SSH after each code change
    2. BIndividual VMs created by hand from a snapshot, with the startup script edited on each one in the console
    3. CA managed instance group with an instance template and health-checked rolling updates
    4. DA Cloud Storage bucket holding the configuration file that each VM reads once at boot
    Show answer and explanation
    Correct answer: A

    A managed instance group built from an instance template keeps the fleet identical and supports rolling updates gated by health checks. Hand-created VMs drift apart from each other, and a single large VM is a single point of failure. Reading configuration only at boot prevents a gradual rollout from ever taking effect on running VMs.

  4. Question 12

    A team uses Cloud Deploy to promote a release from a development target to a production target. Production must require a manual approval, and production must run the exact artifact that passed in development. Which configuration meets both requirements?

    1. AUse a separate Cloud Build trigger for production that deploys the main branch whenever a commit lands
    2. BRebuild the container in the production stage so it reflects the latest dependencies
    3. CSkip the development target and deploy straight to production, with approvals handled by email
    4. DRequire approval on the production target and promote the same release that was tested in development
    Show answer and explanation
    Correct answer: C

    Cloud Deploy lets a target require approval, and promoting one release keeps the same artifact that was tested earlier in the pipeline. Rebuilding in production breaks the link to the tested artifact. A branch-triggered deploy bypasses both the approval and the promotion model.

  5. Question 13

    A new Cloud Run revision failed its startup probe because the container listened on port 8080 while the service expected a different port. What is the most appropriate fix?

    1. ARaise the request timeout so the startup probe waits longer for the port to open
    2. BMove the service to a Compute Engine VM, where any port can be used without configuration
    3. CIncrease the CPU count so the application starts faster and opens the port in time
    4. DMake the application listen on the port in the PORT environment variable that Cloud Run provides
    Show answer and explanation
    Correct answer: C

    Cloud Run passes the port to listen on in the PORT variable, so reading that value keeps the application in step with the platform. A longer timeout does not change which port is listened on. More CPU does not fix a port mismatch, and moving to a VM changes the platform without addressing the cause.

  6. Question 14

    A team must make the deployments of a Cloud Function reproducible and auditable. Which two actions meet this requirement? (Choose two.)

    1. AStore the function source in version control and deploy from a tagged commit
    2. BDeploy from a developer laptop using whatever local files are present at that time
    3. CSet the runtime to a version that is updated automatically for every new minor release
    4. DRecord the build ID and commit SHA as labels on the deployed function
    5. EEdit the function code directly in the console after each deployment
    Show answer and explanation
    Correct answer: A, D

    Deploying from a tagged commit ties the running code to a reviewable source version, and labels that record the build ID and commit SHA make each deployment traceable. Deploying from local files and editing in the console both break the link between code and deployment. Automatic runtime upgrades can change behaviour without any reviewed change.

  7. Question 15

    A Cloud Run service must not receive traffic on a new revision until a health endpoint answers successfully during startup. Which configuration meets this requirement?

    1. AConfigure a startup probe that calls the health endpoint before the revision is ready
    2. BSet the maximum instance count to one until the health check has passed for at least one request
    3. CEnable CPU boost so the container starts faster and the revision is ready sooner after deployment
    4. DSet the minimum instance count to 100 so that enough instances are ready before any traffic is sent
    Show answer and explanation
    Correct answer: A

    A startup probe checks the health endpoint and keeps the revision from receiving traffic until it passes. Limiting instances still lets traffic through once one instance serves a request. CPU boost and large minimum counts do not check readiness, and both add cost.

  8. Question 16

    A GKE Deployment with ten replicas must roll out a new image while keeping at least 90 percent of pods available at all times. Which rolling update strategy meets this requirement?

    1. ASet the Recreate strategy so that all old pods stop before any new pod starts
    2. BSet maxUnavailable to 10 percent and maxSurge to 25 percent in the rolling update strategy
    3. CSet replicas to one and add a PodDisruptionBudget that allows zero disrupted pods during the rollout
    4. DUse a DaemonSet with a node selector so that one pod runs on each node during the update window
    Show answer and explanation
    Correct answer: B

    With maxUnavailable at 10 percent, at most one of ten pods is taken down at a time, and maxSurge lets extra pods start first so capacity stays up. Recreate removes every old pod before new ones start, which causes downtime. A single replica cannot provide 90 percent availability, and a DaemonSet is for node-level agents rather than scaled services.

Designing highly scalable, reliable cloud-native applications (7 questions)

  1. Question 17

    A team runs a stateless Cloud Run service that serves an interactive API. Users report a multi-second delay on the first request after quiet periods, but steady traffic is fast. Which change addresses the cause with the least redesign?

    1. AKeep a minimum number of warm instances ready to serve incoming requests
    2. BRaise the request timeout so slow first requests do not return a 504 error to the client
    3. CMove the service to a regional managed instance group that autoscales on CPU utilization
    4. DEnable session affinity so repeat requests from a client reach the same container instance
    Show answer and explanation
    Correct answer: A

    The delay comes from cold starts, when Cloud Run must start a new container before it can serve a request. A minimum instance count keeps warm instances available, so the first request after a quiet period does not wait for startup. Session affinity only routes a client to the same instance and does nothing for startup latency, and a raised timeout hides the symptom without fixing it.

  2. Question 18

    A payments API receives POST requests from mobile clients that retry after network timeouts, and duplicate charges have occurred. The backend also consumes Pub/Sub messages, which are delivered at least once. What is the most appropriate design change?

    1. AGenerate a new random request ID on each client attempt and write it to the application log
    2. BRaise the Pub/Sub acknowledgement deadline to its maximum so redeliveries happen less often
    3. CReplay failed requests from a Cloud Scheduler job every five minutes until they succeed
    4. DStore a client idempotency key with each completed result and return it on repeat requests
    Show answer and explanation
    Correct answer: D

    Retries and at-least-once delivery both mean the same operation can arrive more than once, so the handler must be idempotent. Storing a client-supplied idempotency key with the completed result lets a repeat return the original outcome instead of charging again. A longer acknowledgement deadline only reduces how often redelivery happens and does not prevent duplicate processing.

  3. Question 19

    A global order-management application needs strongly consistent, relational transactions across users on three continents, and it must scale writes horizontally without manual sharding. Which Google Cloud database fits best?

    1. ACloud SQL for PostgreSQL with cross-region read replicas in each continent
    2. BCloud Spanner configured as a multi-region instance
    3. CBigtable with a multi-cluster routing policy spanning three regions
    4. DFirestore in Native mode with a single-region location near headquarters
    Show answer and explanation
    Correct answer: A

    Cloud Spanner provides relational schemas, ACID transactions and synchronous replication across a multi-region configuration, and it scales horizontally. Cross-region read replicas in Cloud SQL do not give globally consistent writes, because writes still go to one primary. Bigtable scales well but is a wide-column store without multi-row relational transactions.

  4. Question 20

    A consumer service must process order events for each customer in the exact order they were published, while events for different customers can be processed in parallel. Which Pub/Sub configuration meets this requirement?

    1. ACreate one topic per customer so that each topic preserves its own publish order
    2. BUse a push subscription with an exponential retry policy so failed messages are redelivered in sequence
    3. CEnable message ordering and set the customer ID as the ordering key on every publish
    4. DSet the subscription acknowledgement deadline to 600 seconds so each message completes before the next
    Show answer and explanation
    Correct answer: C

    Pub/Sub guarantees order only for messages that share an ordering key when message ordering is enabled on the publisher and subscription. Using the customer ID as the key keeps each customer ordered while allowing different customers in parallel. One topic per customer does not scale, and retry policies and acknowledgement deadlines do not guarantee ordered delivery.

  5. Question 21

    A service on Cloud Run uses a Cloud SQL instance. During a traffic spike, the database rejects new connections because too many container instances open connections at once. Which design change is most appropriate?

    1. AReplace Cloud SQL with a Memorystore for Redis instance so the application no longer needs any relational database connections
    2. BStore the database credentials in Secret Manager and rotate them every hour during traffic spikes
    3. CIncrease the Cloud SQL machine type and leave the service's maximum instance count unlimited
    4. DPool connections inside each instance through the Cloud SQL connector and cap the service's maximum instance count
    Show answer and explanation
    Correct answer: D

    Each Cloud Run instance opens its own connections, so the total grows with the instance count. Pooling inside each instance and capping the maximum instance count keeps the total within the database limit, while the Cloud SQL connector handles secure connectivity. A larger machine only raises the limit, and Memorystore is a cache that cannot replace a relational store.

  6. Question 22

    A stateful application keeps user sessions in the memory of each Cloud Run instance. After scaling out, users are logged out at random. Which change is the most appropriate?

    1. ASet minimum instances equal to maximum so instances never scale down and drop sessions
    2. BIncrease the instance memory so more sessions fit before the service scales out
    3. CEnable session affinity so each user is routed to the instance that holds the session in memory
    4. DMove session state to a shared store such as Memorystore for Redis or Firestore
    Show answer and explanation
    Correct answer: D

    Cloud Run instances are stateless and can be created or removed at any time, so session data must live in a shared store that any instance can read. Session affinity is a workaround that breaks on scale-in and restarts. More memory and fixed instance counts only delay the failure.

  7. Question 23

    A team designs a Cloud Run service that must keep working when one zone fails and must recover quickly from a bad deployment. Which two design choices best meet these goals? (Choose two.)

    1. APin the service to a single zone to reduce cross-zone latency to the database
    2. BKeep all application state on the container's local disk so restarts are faster
    3. CSet the maximum instance count to one so that only one instance handles any failure
    4. DUse Cloud Run revisions with traffic shifting, so the previous revision can take traffic again quickly
    5. EUse regional resources such as Cloud SQL with high availability enabled, not a single-zone instance
    Show answer and explanation
    Correct answer: D, E

    Cloud Run is a regional service that spreads instances across zones, and traffic shifting between revisions gives a fast rollback path. High availability on a regional database keeps data reachable when one zone fails. A single zone, local state and a maximum of one instance each create a single point of failure.

Building and testing applications (7 questions)

  1. Question 24

    A developer needs to run unit tests for a Cloud Function that reads from Firestore. The tests must not write to production data and must run on a laptop without network access to Google Cloud. What should the developer use?

    1. AA second Firestore database in the production project, with the developer's user granted write access
    2. BA service account key with the Owner role on a shared sandbox project that uses production data
    3. CAn export of the production database to Cloud Storage, which the tests read as local JSON files
    4. DThe Firestore emulator started locally, with the client pointed at it through FIRESTORE_EMULATOR_HOST
    Show answer and explanation
    Correct answer: D

    The Firestore emulator runs locally, and the client libraries switch to it when FIRESTORE_EMULATOR_HOST is set, so tests need no network access and cannot reach production data. A second database in the production project still depends on the cloud and risks mixing data. Exports are snapshots rather than a live test target, and owner-level keys break least privilege.

  2. Question 25

    A Cloud Build pipeline must build a container image and push it to Artifact Registry only if the unit tests pass. Which cloudbuild.yaml structure achieves this?

    1. AOrder the steps so the test step runs first and each later step waits for it to succeed
    2. BSet waitFor to '-' on the build and push steps so they start in parallel with the tests
    3. CUpload the test results to a Cloud Storage bucket and have the deploy step read those results
    4. DSet allowFailure to true on the test step and check the build log manually before any push
    Show answer and explanation
    Correct answer: A

    Cloud Build runs steps in the order listed unless waitFor says otherwise, and a failed step stops the build by default. Placing the test step first, with later steps depending on it, means the image is never pushed when tests fail. Setting waitFor to '-' starts steps in parallel and removes the dependency on tests, which is the opposite of the requirement.

  3. Question 26

    A team wants its integration tests for a Cloud Run service to exercise the real Pub/Sub and Firestore APIs on every pull request, without sharing long-lived credentials. Which setup best meets this goal?

    1. AStore a single owner-level service account key in the repository and reuse it in every pipeline run
    2. BUse a disposable project per pull request, with a scoped service account for the tests
    3. CMock every Google Cloud client call with hand-written stubs and skip the real APIs entirely
    4. DRun the tests against the production Pub/Sub topic and filter out test messages with a label
    Show answer and explanation
    Correct answer: B

    A disposable project per pull request isolates test data and lets the pipeline use a scoped service account rather than a long-lived shared key. Storing an owner key in the repository violates least privilege and secret handling. Running tests against production risks real data, and pure stubs do not test the real API behaviour the requirement names.

  4. Question 27

    A Java developer suspects a race condition in a request handler that uses a shared in-memory cache. Which approach is most likely to surface the bug before deployment?

    1. AIncrease the instance CPU limit so extra processing headroom hides the timing problem
    2. BRead the handler during peer review and confirm that each function is short and clearly named
    3. CRun concurrent load tests against a deployed staging revision and watch the error rates
    4. DDisable the shared cache in unit tests so the handler never reaches the shared state path
    Show answer and explanation
    Correct answer: C

    A race condition appears only under concurrent access, so concurrent load against a realistic environment is the approach most likely to expose it. Code review can catch some issues but does not reproduce timing. More CPU hides the symptom, and disabling the cache removes the very code path under test.

  5. Question 28

    Latency increased for a Cloud Run service after a release, and the team needs to find which call is responsible without changing production traffic. Which check should the developer make first?

    1. AReview the Cloud Logging sink that exports request logs to BigQuery to count how many requests arrived
    2. BCompare Cloud Trace span breakdowns for the affected endpoint between the old and new revisions
    3. CCheck the Cloud Monitoring uptime check frequency to confirm the service is reachable from outside Google
    4. DReview the Cloud Storage lifecycle policy on the bucket that serves the application's static assets
    Show answer and explanation
    Correct answer: B

    Cloud Trace records per-request spans, so comparing the span breakdown for the affected endpoint across revisions shows which call grew. A log export counts requests but does not show where time went. Uptime checks measure reachability rather than latency inside the service, and storage lifecycle policies are unrelated to request latency.

  6. Question 29

    A developer must verify that a new Cloud Run revision honours the same API contract as the previous one before it receives user traffic. Which control is the most appropriate?

    1. ASend the new revision 100 percent of traffic and roll back on the first error that appears in logs
    2. BDelete the previous revision so only the new revision exists and the deployment enforces the contract
    3. CSet the minimum instance count to zero so that cold starts reveal any startup contract errors
    4. DDeploy the revision with no traffic assigned and run contract tests against its tagged URL first
    Show answer and explanation
    Correct answer: D

    Revision tags let a team deploy with no traffic and test the new revision through its own URL, so the contract is checked before users are affected. Shifting full traffic first and rolling back reactively exposes users to the failure. Deleting the old revision removes the rollback path, and minimum instance settings have nothing to do with contract checks.

  7. Question 30

    A team wants its Cloud Build pipeline to produce reproducible images and avoid breaking builds when upstream packages change. Which two practices best achieve this? (Choose two.)

    1. APin dependency versions with a lockfile and commit it to the repository
    2. BUse the latest tag on the builder image so that security patches are always included
    3. CRun the integration suite against the production Cloud SQL instance to match real data
    4. DSkip the test stage on pull requests to reduce build minutes and cost
    5. EPin the base image to a specific digest and update it through a reviewed change
    Show answer and explanation
    Correct answer: A, E

    Lockfiles fix dependency versions so the same inputs produce the same build, and pinning the base image by digest stops silent changes from upstream. A latest tag changes underneath the build. Running against production risks real data, and skipping tests on pull requests lets regressions merge.