GPCD

Free GPCD practice questions

10 questions from our GPCD practice tests, each with the correct answer and a written explanation. Read them with the answers shown, or switch to quiz mode and answer first.

Back to the GPCD practice exams

Question 1 of 10, Designing highly scalable, secure, and reliable cloud-native applications

A developer must store database passwords and third-party API tokens for a Cloud Run service. Security requires automatic version history, IAM-controlled access per secret, and audit logs of every access. What should the developer use?

  1. ACloud Storage, storing the credentials in a bucket that uses CMEK and uniform bucket-level access for every object
  2. BSecret Manager, granting only the service's own service account the Secret Accessor role on each secret Correct answer
  3. CRuntime environment variables set in the Cloud Run service YAML and restricted with the Cloud Run Developer role
  4. DCloud KMS, encrypting each credential with a key and storing the ciphertext as a Cloud Run environment variable

Answer and explanation: Secret Manager versions every secret, supports IAM bindings on individual secrets, and records access in Cloud Audit Logs; granting the Secret Accessor role only to the service's own service account follows least privilege. Cloud KMS manages keys rather than storing secrets, so the team would have to build versioning and distribution themselves. A CMEK bucket encrypts objects but is not designed for secret versioning and per-secret access workflows. Plain environment variables are visible to anyone who can view the service configuration and have no per-access audit trail.

Question 2 of 10, Designing highly scalable, secure, and reliable cloud-native applications

A payments API exposed to partners must enforce per-partner quotas, verify API keys, transform legacy SOAP requests into REST calls, and give product managers analytics and a developer portal for onboarding. Which solution should the developer recommend?

  1. AAPI Gateway, with an OpenAPI specification that defines API keys and a quota per consumer project
  2. BApigee, with API products that carry quotas, key verification, and SOAP-to-REST mediation policies Correct answer
  3. CAn external Application Load Balancer with Cloud Armor rate-limiting rules keyed on a partner header
  4. DCloud Endpoints with the Extensible Service Proxy V2 deployed as a sidecar next to each backend

Answer and explanation: Apigee is the full API management platform: API products bundle quotas and key verification, policies can mediate SOAP to REST, and it provides analytics and an integrated developer portal. API Gateway supports API keys and simple quotas but has no protocol mediation or partner-facing developer portal. Cloud Endpoints with ESPv2 offers authentication and monitoring but also lacks mediation and portal capabilities. Cloud Armor rate limiting throttles traffic but does not manage API keys, transform payloads, or provide API analytics.

Question 3 of 10, Designing highly scalable, secure, and reliable cloud-native applications

A service on GKE calls a Cloud SQL for PostgreSQL instance that has only a private IP. Security requires IAM-based authorization for database connections and encryption in transit, without managing SSL certificates in the application. What should the developer do?

  1. ARun the Cloud SQL Auth Proxy as a sidecar using Workload Identity Federation for GKE and IAM database authentication Correct answer
  2. BExpose the instance through a Private Service Connect endpoint and connect with the built-in postgres user and password
  3. CAdd the GKE node IP ranges to the instance's authorized networks and require SSL connections
  4. DConnect directly to the private IP with a database password stored in a Kubernetes Secret

Answer and explanation: The Cloud SQL Auth Proxy authorizes connections with IAM, encrypts traffic with TLS automatically, and with Workload Identity Federation for GKE uses the pod's mapped identity; IAM database authentication removes static passwords. A direct private IP connection with a password lacks IAM authorization and automatic TLS. Authorized networks apply to public IP and would require managing certificates. A Private Service Connect endpoint provides private reachability but not IAM-based authorization or automatic encryption by itself.

Question 4 of 10, Building and testing applications

A team runs integration tests in Cloud Build that need a real PostgreSQL database and a Pub/Sub emulator. The tests must run in isolation for every pull request without touching shared environments. Which approach is BEST?

  1. APoint each build at the shared staging Cloud SQL instance and truncate all tables before the integration tests start
  2. BMock every database and Pub/Sub call in unit tests, then skip integration testing in Cloud Build entirely
  3. CRun the tests only after deployment to production by adding a smoke test step to the Cloud Deploy pipeline
  4. DRun PostgreSQL and the Pub/Sub emulator as detached containers on the cloudbuild network, then run the tests Correct answer

Answer and explanation: Cloud Build steps run as containers on a shared Docker network named cloudbuild, so a step can start PostgreSQL and the emulator in detached mode and later steps reach them by name, giving isolated, disposable dependencies per build. A shared staging instance causes interference between concurrent pull requests. Testing only in production finds integration bugs too late. Mocks are useful for unit tests but do not verify real integration behaviour.

Question 5 of 10, Building and testing applications

A team wants Gemini Code Assist in their IDE to follow internal conventions, such as the approved logging library and error-handling style, without repeating them in every prompt. What should they do?

  1. AAsk each developer to state the conventions at the start of each chat session in the IDE before asking for code
  2. BDisable code completion and use only the chat panel so that every answer is reviewed manually
  3. CPaste the full style guide into a code comment at the top of every source file in the repository
  4. DAdd a repository context file listing the conventions, which the assistant includes with requests Correct answer

Answer and explanation: Context engineering means supplying persistent, relevant instructions, such as a context or rules file in the repository, so the assistant applies team conventions automatically. Comments in every file add noise and are not a reliable instruction channel. Disabling completion does not teach the assistant the conventions. Repeating conventions per session is error-prone and inconsistent.

Question 6 of 10, Configuring cloud-native applications for deployment

A GKE pod loads a large machine learning model at start-up, which can take up to three minutes. The liveness probe restarts the container before loading finishes. What should the developer add?

  1. AA higher initialDelaySeconds on the readiness probe and a lower timeout on the liveness probe
  2. BA PodDisruptionBudget with minAvailable set to one so that the pod cannot be restarted early
  3. CA readiness probe with a short period so that the pod is removed from Service endpoints while loading
  4. DA startup probe whose failureThreshold multiplied by periodSeconds covers at least three minutes Correct answer

Answer and explanation: A startup probe holds off liveness and readiness probes until it succeeds, so failureThreshold multiplied by periodSeconds can cover the slow model load without weakening the liveness probe afterwards. A readiness probe keeps traffic away but does not stop liveness restarts. Changing readiness delay and shortening the liveness timeout makes restarts more likely. A PodDisruptionBudget limits voluntary evictions, not kubelet restarts caused by failed probes.

Question 7 of 10, Configuring cloud-native applications for deployment

A Pub/Sub push subscription delivers messages to a Cloud Run service. Processing takes up to eight minutes, and messages are redelivered while the first attempt is still running. What should the developer change?

  1. AIncrease only the Cloud Run request timeout to 60 minutes, leaving the subscription's ack deadline at its default
  2. BRaise the subscription's ack deadline above the processing time, and keep the Cloud Run timeout above it Correct answer
  3. CEnable message ordering, because ordered delivery prevents a message from being sent twice in parallel
  4. DReduce the Cloud Run concurrency to one so that each instance processes only a single push request

Answer and explanation: For push subscriptions, the ack deadline is how long Pub/Sub waits for an HTTP response before redelivering, so it must exceed processing time (the maximum is 600 seconds), and the Cloud Run timeout must be at least as long. Raising only the Cloud Run timeout still lets Pub/Sub redeliver after the default deadline. Ordering does not prevent redelivery after a deadline expires. Concurrency changes do not stop deadline-based redelivery.

Question 8 of 10, Configuring cloud-native applications for deployment

A Deployment on GKE must be reachable from the internet through HTTPS with a Google-managed certificate and path-based routing to two services. Which approach should the developer use?

  1. AA Gateway with a global external Application Load Balancer class, HTTPRoutes, and a managed certificate Correct answer
  2. BA Service of type LoadBalancer for each Deployment, with certificates stored in Kubernetes Secrets and mounted into pods
  3. CA Service of type ClusterIP with kubectl port-forward running on a bastion host for users
  4. DA Service of type NodePort with firewall rules opening the port to 0.0.0.0/0 on every node

Answer and explanation: The GKE Gateway controller provisions an Application Load Balancer from Gateway and HTTPRoute resources, supporting path-based routing and Google-managed certificates. A LoadBalancer Service creates a passthrough Network Load Balancer per service, without layer 7 path routing or managed certificates. NodePort exposure is insecure and lacks TLS termination. Port-forwarding is a debugging tool, not production ingress.

Question 9 of 10, Integrating applications with Google Cloud services

A bug in a subscriber processed the last six hours of Pub/Sub messages incorrectly. The fix is deployed, and the messages were already acknowledged. How can the team reprocess them?

  1. ASeek the subscription to a timestamp six hours ago, given message retention covers that window Correct answer
  2. BIncrease the ack deadline so that the acknowledged messages are redelivered to the subscriber
  3. CPublish the six hours of messages again by reading them back from the subscription's dead-letter topic
  4. DRecreate the subscription, which automatically delivers all messages published in the past day

Answer and explanation: Seeking to a time redelivers retained messages published after that time, provided acknowledged-message retention or topic retention covers the window. A new subscription only receives messages published after it is created, unless it is seeked using topic retention. Successfully processed messages never reach a dead-letter topic. The ack deadline does not affect already acknowledged messages.

Question 10 of 10, Integrating applications with Google Cloud services

An inventory service consumes Pub/Sub messages. Updates for the same product must be processed in the order they were published, while different products can be processed in parallel. What should the developer configure?

  1. AAdd a sequence number attribute and sort messages in memory before processing each batch
  2. BEnable message ordering on the subscription and publish with the product ID as the ordering key Correct answer
  3. CEnable exactly-once delivery on the subscription, which also preserves publish order
  4. DUse a single subscriber with one thread so that all messages are processed one at a time

Answer and explanation: With ordering enabled and the product ID as ordering key, messages with the same key are delivered in order while different keys proceed in parallel. A single thread serializes everything and kills throughput. Sorting in memory fails across batches and subscriber instances. Exactly-once delivery prevents redelivery after a successful acknowledgement but does not guarantee order.