Question 56 of 999
Integrating Google Cloud serviceshardMultiple ChoiceObjective-mapped

Exactly-Once Processing: Idempotent Writes from Pub/Sub to Firestore

This PCD practice question tests your understanding of integrating google cloud services. Read the scenario carefully and evaluate each option against the stated constraints before committing to an answer. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

You are designing a system that ingests high-velocity event streams from IoT devices using Pub/Sub. Each event must be processed exactly once to update a Firestore database. However, due to the distributed nature, at-least-once delivery is guaranteed by Pub/Sub. Which design pattern should you use to achieve exactly-once processing?

Clue words in this question

Noticing these words before you look at the options changes how you read each choice.

  • Clue: "least"

    Why it matters: You want the option with minimum overhead, fewest steps, or lowest impact — not the most feature-rich or comprehensive answer.

Quick Answer

The answer is to make the message processor idempotent by using a unique event ID as the Firestore document ID and performing upsert operations. This works because idempotent writes ensure that processing the same Pub/Sub message multiple times—a consequence of its at-least-once delivery guarantee—results in only one effective state change in Firestore. By deriving the document ID from a unique, deterministic event attribute, any duplicate write simply overwrites the same document with the same data, making the operation harmless and achieving exactly-once processing semantics without relying on external deduplication. On the Google Professional Cloud Developer exam, this question tests your understanding that Pub/Sub guarantees at-least-once delivery, so you must design for idempotency at the sink; a common trap is assuming Firestore or Dataflow can magically deduplicate for you. Remember the mnemonic: "ID for ID" — use the unique event ID as the document ID to make your writes idempotent.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Make the message processor idempotent by using a unique event ID as the Firestore document ID, and perform upsert operations.

Option D is correct because making the message processor idempotent by using a unique event ID as the Firestore document ID ensures that even if Pub/Sub delivers the same event multiple times (at-least-once semantics), the upsert operation will overwrite the document with the same data, resulting in exactly-once processing. This pattern leverages Firestore's document-level write semantics without requiring additional infrastructure for deduplication.

Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Use a Cloud Function with a retry policy to ensure delivery, and deduplicate using a Cloud Bigtable row key.

    Why it's wrong here

    Bigtable row keys can help but the primary pattern is idempotency.

  • Use Cloud Dataflow with exactly-once processing mode and write to Firestore using a custom sink.

    Why it's wrong here

    Dataflow exactly-once still requires idempotent writes to the sink.

  • Use a Cloud Run service to pull messages and write to Firestore; rely on Firestore's built-in deduplication using document IDs.

    Why it's wrong here

    Firestore does not automatically deduplicate based on document ID.

  • Make the message processor idempotent by using a unique event ID as the Firestore document ID, and perform upsert operations.

    Why this is correct

    Idempotent processing with upsert ensures exactly-once effect.

    Clue confirmation

    The clue word "least" in the question point toward this answer.

    Related concept

    Read the scenario before looking for a memorised answer.

Common exam traps

Common exam trap: answer the scenario, not the keyword

A common misconception is that Firestore has built-in deduplication or that Cloud Dataflow's exactly-once mode automatically guarantees exactly-once writes to any sink, when in reality the sink must support idempotent writes or the pipeline must implement idempotency logic.

Detailed technical explanation

How to think about this question

Under the hood, Pub/Sub uses a unique `message_id` for each published message, but due to its at-least-once delivery guarantee, a subscriber may receive the same `message_id` multiple times. By using a deterministic event ID (e.g., a UUID or a hash of the event payload) as the Firestore document ID, the upsert operation (`set()` with `merge: true` or `create()`) becomes idempotent: subsequent writes with the same document ID will not create a new document but update the existing one. This pattern is critical in real-world IoT pipelines where network retries or Pub/Sub redeliveries are common, and it avoids the cost and complexity of external deduplication stores.

KKey Concepts to Remember

  • Read the scenario before looking for a memorised answer.
  • Find the constraint that changes the correct option.
  • Eliminate answers that are true in general but not in this case.

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Real-world example

How this comes up in practice

A company's IT admin needs to give a contractor read-only access to production logs without sharing account credentials. Using role-based access control (RBAC) and temporary scoped permissions — not a permanent shared password — is the correct pattern. Questions like this test whether you can apply least-privilege access across cloud identity services.

What to study next

Got this wrong? Here's your next step.

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Related practice questions

Related PCD practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Manage a Solution that Can Span Multiple Database Systems practice questions

Practise PCD questions linked to Manage a Solution that Can Span Multiple Database Systems.

Deploy Scalable and Highly Available Databases in Google Cloud practice questions

Practise PCD questions linked to Deploy Scalable and Highly Available Databases in Google Cloud.

Design Scalable and Highly Available Cloud Database Solutions practice questions

Practise PCD questions linked to Design Scalable and Highly Available Cloud Database Solutions.

Migrate Data Solutions practice questions

Practise PCD questions linked to Migrate Data Solutions.

Designing highly scalable, available, and reliable cloud-native applications practice questions

Practise PCD questions linked to Designing highly scalable, available, and reliable cloud-native applications.

Building and testing applications practice questions

Practise PCD questions linked to Building and testing applications.

Deploying applications practice questions

Practise PCD questions linked to Deploying applications.

Integrating Google Cloud services practice questions

Practise PCD questions linked to Integrating Google Cloud services.

Managing application performance monitoring practice questions

Practise PCD questions linked to Managing application performance monitoring.

PCD fundamentals practice questions

Practise PCD questions linked to PCD fundamentals.

PCD scenario practice questions

Practise PCD questions linked to PCD scenario.

PCD troubleshooting practice questions

Practise PCD questions linked to PCD troubleshooting.

Practice this exam

Start a free PCD practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this PCD question test?

Integrating Google Cloud services — This question tests Integrating Google Cloud services — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: Make the message processor idempotent by using a unique event ID as the Firestore document ID, and perform upsert operations. — Option D is correct because making the message processor idempotent by using a unique event ID as the Firestore document ID ensures that even if Pub/Sub delivers the same event multiple times (at-least-once semantics), the upsert operation will overwrite the document with the same data, resulting in exactly-once processing. This pattern leverages Firestore's document-level write semantics without requiring additional infrastructure for deduplication.

What should I do if I get this PCD question wrong?

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Are there clue words in this question I should notice?

Yes — watch for: "least". You want the option with minimum overhead, fewest steps, or lowest impact — not the most feature-rich or comprehensive answer.

What is the key concept behind this question?

Read the scenario before looking for a memorised answer.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Keep practising

More PCD practice questions

Last reviewed: Jul 4, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

This PCD practice question is part of Courseiva's free Google Cloud certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCD exam.