mediumMultiple ChoiceObjective-mapped
Google ACE Practice Question: A Cloud Function (gen2) is triggered by Pub/Sub…
A Cloud Function (gen2) is triggered by Pub/Sub messages. The function processes each message by calling three external APIs sequentially. The total processing time is 25 seconds per message. The Pub/Sub subscription's ack deadline is 10 seconds. What will happen, and how should you fix it?
⚠ Common exam trap
It's easy for candidates to assume Cloud Functions automatically handle Pub/Sub ack deadlines or that increasing resources speeds up I/O-bound operations, but the exam tests understanding of the explicit ack deadline configuration and the need to match it to processing time.
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
✓
Messages will be redelivered before processing completes; extend the Pub/Sub subscription ack deadline to exceed 25 seconds.
The Pub/Sub subscription has a 10-second ack deadline, but the Cloud Function takes 25 seconds to process each message. Since the function does not acknowledge the message within the deadline, Pub/Sub considers the message unacknowledged and redelivers it, causing duplicate processing. The fix is to increase the ack deadline to exceed 25 seconds, ensuring the function has enough time to complete processing and send an acknowledgment.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Pub/Sub will wait indefinitely for the function to acknowledge; no issue occurs.
Why it's wrong here
Pub/Sub does not wait indefinitely for an acknowledgement. When the ack deadline expires, the message becomes eligible for redelivery, which causes the same message to be processed twice—the exact problem the deadline is designed to avoid. Assuming no issue occurs ignores the core redelivery guarantee, so this answer is incorrect.
- ✓
Messages will be redelivered before processing completes; extend the Pub/Sub subscription ack deadline to exceed 25 seconds.
Why this is correct
In Pub/Sub push delivery, the ack deadline defines how long the service waits for the subscriber to acknowledge. If the Cloud Function runs longer than the subscription's ack deadline (commonly 10 seconds by default), Pub/Sub redelivers the message to another instance before processing finishes. Configure the subscription's ack deadline to a value greater than 25 seconds—for example, 60 seconds—so the function can complete and return 200 OK to acknowledge before any redelivery.
- ✗
The Cloud Function will automatically extend its own ack deadline via the Pub/Sub client library.
Why it's wrong here
Acknowledgment deadline extension via ModifyAckDeadline works only for pull subscribers; push subscribers like Cloud Functions have no API to change the deadline from within the execution. The function must simply finish before the configured deadline and return HTTP 200 to the push endpoint. It cannot extend the deadline itself, so relying on automatic extension is invalid.
- ✗
Increase the Cloud Function's memory to process faster and complete within 10 seconds.
Why it's wrong here
The delay stems from sequential calls to an external API, which are I/O-bound network operations, not compute-bound work. Increasing the Cloud Function's memory only raises CPU and memory allocation, which cannot reduce the latency of the external API responses. Even with more memory, the function would still wait roughly 25 seconds for those calls, so it would not reliably finish within 10 seconds.
Go deeper
Related to this question
About these practice questions
One of 769 original ACE practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This ACE 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 ACE exam.