Google PCD: API Design, Integration and Event-Driven Development — Study Guide

Part of the Google Professional Cloud Developer — Study Guide. Practice with verified answers in the Google exam hub, or take timed practice tests on ExamRoll.io.

Overview

Modern application integration on Google Cloud blends well-designed synchronous APIs with resilient asynchronous and event-driven patterns. The goal is to provide clear contracts, strong identity, consistent error handling, and operational controls that keep latency low and availability high even under failure, scaling, or change. This section covers protocol and API choices, gateways and auth, messaging and event routing, background work, orchestration, identity and trust between services, reliability patterns, secure webhooks, and safe schema evolution.

API Design and Management

Choose the right protocol:

Versioning and pagination:

Validation and errors:

API management choices:

Authentication and quotas:

Minimal API Gateway OpenAPI example with Cloud Run backend and OIDC:

openapi: 3.0.0
info: {title: orders, version: 1.0.0}
paths:
  /v1/orders:
    get:
      security: [{firebase: []}]
      x-google-backend: {address: https://orders-xyz-uc.a.run.app}
      responses: {"200": {description: OK}}
components:
  securitySchemes:
    firebase:
      type: http
      scheme: bearer
      bearerFormat: JWT
      x-google-issuer: https://securetoken.google.com/PROJECT_ID
      x-google-audiences: PROJECT_ID

Asynchronous Messaging and Eventing

Pub/Sub fundamentals:

Create topic, subscription, and DLQ:

gcloud pubsub topics create orders
gcloud pubsub topics create orders-dlq
gcloud pubsub subscriptions create orders-sub \
  --topic=orders \
  --dead-letter-topic=orders-dlq \
  --max-delivery-attempts=5 \
  --ack-deadline=30

Consumer reasoning: implement idempotent handlers and deduplication (e.g., by messageId or application-level idempotency key); retry transient errors with backoff; move irrecoverable messages to DLQ and alert.

Eventarc and CloudEvents:

Create an Eventarc trigger for Cloud Storage object finalization:

gcloud eventarc triggers create index-new-objects \
  --destination-run-service=media-indexer \
  --destination-run-region=us-central1 \
  --event-filters="type=google.cloud.storage.object.v1.finalized" \
  --event-filters="bucket=my-assets-bucket" \
  --service-account=eventarc-router@PROJECT_ID.iam.gserviceaccount.com

Trade-offs:

Orchestration, Background Work, and Long-Running Processes

Cloud Tasks:

Create a queue with rate limits and retries:

gcloud tasks queues create payments-queue \
  --max-dispatches-per-second=50 \
  --max-concurrent-dispatches=200 \
  --max-attempts=10 \
  --min-backoff=5s \
  --max-backoff=300s

Workflows:

Compensation sketch:

main:
  params: [orderId]
  steps:
  - charge:
      call: http.post
      args: {url: ${paymentsUrl}/charge, auth: {type: OIDC}, body: {orderId: ${orderId}}}
      result: chargeRes
  - reserveInventory:
      try:
        steps:
        - reserve:
            call: http.post
            args: {url: ${inventoryUrl}/reserve, auth: {type: OIDC}, body: {orderId: ${orderId}}}
      except:
        as: e
        steps:
        - refund:
            call: http.post
            args: {url: ${paymentsUrl}/refund, auth: {type: OIDC}, body: {paymentId: ${chargeRes.body.id}}}
        - raise: ${e}

Operational guidance:

Identity, Reliability, and Integrations

Service-to-service identity and token propagation:

Fetch an ID token in Cloud Run:

AUD="https://inventory-xyz-uc.a.run.app"
TOKEN=$(curl -s -H "Metadata-Flavor: Google" \
  "http://metadata/computeMetadata/v1/instance/service-accounts/default/identity?audience=${AUD}")
curl -H "Authorization: Bearer ${TOKEN}" "${AUD}/v1/check"

Synchronous dependencies and resilience:

Webhooks and third-party integrations:

Schema evolution and compatibility:

Security and quotas across the stack:

Practical Problem Scenario

AcmeRetail is building a click-to-collect service on Google Cloud. A React web app calls a public API to place orders; backend services must reserve inventory, charge payments, and notify stores. The team needs low-latency APIs, reliable background processing, event-driven updates, and safe rollback on partial failures.

Approach:

  1. Expose a public REST API via API Gateway in front of a Cloud Run orders service.
  1. Implement service-to-service calls with gRPC for internal hot paths (orders to inventory, pricing).
  1. Use Workflows to orchestrate the order saga: charge payment, reserve inventory, create pickup task; compensate on failure.
  1. Publish domain events to Pub/Sub topics orders and inventory for downstream consumers (analytics, store notifications).
  1. Trigger store notifications via Eventarc to a Cloud Run notifier service on relevant Cloud Storage and Firestore changes.
  1. Handle payment provider webhooks with a dedicated Cloud Run endpoint fronted by API Gateway, verifying HMAC signatures and using Cloud Tasks for processing.
  1. Enforce reliability patterns: circuit breakers at Apigee or Envoy for outbound calls to the payment provider; client timeouts set below provider SLAs; retries with truncated exponential backoff for 429/5xx.
  1. Adopt schema evolution controls: Protobuf for internal gRPC with reserved fields; REST responses use additive JSON changes; Pub/Sub uses Protobuf schema validation at publish time.
  1. Observe and operate: propagate trace headers between API Gateway and services; export Cloud Logging metrics for error rates and DLQ size; alert on SLO burn and 429/5xx anomalies.

Compute · All domains · Application Data

Practice these questions → · Timed practice on ExamRoll.io →

Pass the whole exam — not just this question

You found this answer. Get every verified question and explanation in one place, and save hours of prep. Free to start.

Pass your exam →

Browse Google →

Related guides

All-in-one access

One subscription. Every exam.

Every plan unlocks unlimited answer search, practice tests, AI explanations, and the full resource library — in 20+ languages.

Monthly
24.87
Just €0.83/day
Everything included:
  • Unlimited answer search
  • Unlimited practice tests
  • AI-powered explanations
  • Full resource library
  • 20+ languages
  • Weekly content updates
  • Rewards & referrals
  • Priority support
Start free trial

No credit card required*

Best value
12 months
179.87
Just €0.49/daySave 40%
Everything included:
  • Unlimited answer search
  • Unlimited practice tests
  • AI-powered explanations
  • Full resource library
  • 20+ languages
  • Weekly content updates
  • Rewards & referrals
  • Priority support
Start free trial

No credit card required*

✓ Free plan included · ✓ Cancel anytime · ✓ All plans unlock the full product