Bird
Raised Fist0
GCPcloud~20 mins

Pub/Sub vs Cloud Tasks in GCP - Practice Questions

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Pub/Sub vs Cloud Tasks Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Pub/Sub Message Delivery

Which statement best describes how Google Cloud Pub/Sub handles message delivery?

APub/Sub guarantees exactly-once delivery of messages to subscribers.
BPub/Sub guarantees at-least-once delivery, so messages may be delivered more than once.
CPub/Sub delivers messages only once and drops duplicates automatically.
DPub/Sub does not retry message delivery if a subscriber fails to acknowledge.
Attempts:
2 left
💡 Hint

Think about how Pub/Sub ensures messages are not lost but might be repeated.

❓ Architecture
intermediate
2:00remaining
Choosing Between Pub/Sub and Cloud Tasks for Task Execution

You need to design a system that processes user requests with guaranteed execution and ordered processing. Which service is more suitable?

AUse Pub/Sub because it guarantees ordered message processing and exactly-once delivery.
BUse Cloud Tasks because it supports task scheduling, retries, and ordered execution.
CUse Pub/Sub because it supports task scheduling and delayed execution natively.
DUse Cloud Tasks because it only supports fire-and-forget messaging without retries.
Attempts:
2 left
💡 Hint

Consider which service supports task ordering and retries explicitly.

❓ service_behavior
advanced
2:00remaining
Pub/Sub Subscription Acknowledgment Behavior

What happens if a Pub/Sub subscriber does not acknowledge a message within the ack deadline?

AThe message is deleted and never redelivered.
BThe message is redelivered to the same or another subscriber after the ack deadline expires.
CThe message is moved to a dead-letter queue immediately.
DThe subscriber is disconnected and must reconnect manually.
Attempts:
2 left
💡 Hint

Think about how Pub/Sub ensures message processing reliability.

❓ security
advanced
2:00remaining
Securing Cloud Tasks Execution

Which method is recommended to securely authenticate HTTP targets when Cloud Tasks dispatches tasks?

AUse API keys embedded in the task payload.
BUse OAuth 2.0 tokens or OIDC tokens generated by Cloud Tasks for authentication.
CUse basic authentication with username and password in the URL.
DNo authentication is needed because Cloud Tasks runs inside Google Cloud.
Attempts:
2 left
💡 Hint

Consider secure token-based authentication methods supported by Cloud Tasks.

✅ Best Practice
expert
3:00remaining
Handling High Throughput with Pub/Sub and Cloud Tasks

You have a system that must handle millions of user events per day with low latency and guaranteed processing. Which architecture best balances scalability and reliability?

AUse Pub/Sub to ingest events and Cloud Tasks to process critical tasks with retries and ordering.
BUse only Cloud Tasks for all events to ensure ordering and retries at scale.
CUse Pub/Sub with no retries and process events directly without task queues.
DUse Cloud Tasks to ingest events and Pub/Sub to process tasks asynchronously.
Attempts:
2 left
💡 Hint

Think about combining services to leverage their strengths for scale and reliability.

Practice

(1/5)
1. Which Google Cloud service is best suited for sending messages to multiple subscribers quickly and asynchronously?
easy
A. Cloud Functions
B. Cloud Tasks
C. Pub/Sub
D. Cloud Run

Solution

  1. Step 1: Understand Pub/Sub's purpose

    Pub/Sub is designed to send messages to many subscribers quickly and asynchronously, enabling event-driven architectures.
  2. Step 2: Compare with Cloud Tasks

    Cloud Tasks manages individual work items with control over retries and timing, not broad message delivery.
  3. Final Answer:

    Pub/Sub -> Option C
  4. Quick Check:

    Event broadcasting = Pub/Sub [OK]
Hint: Pub/Sub = many subscribers fast; Cloud Tasks = controlled retries [OK]
Common Mistakes:
  • Confusing Cloud Tasks as a message broadcaster
  • Thinking Pub/Sub controls task retries
  • Mixing Cloud Functions with messaging services
2. Which of the following is the correct way to create a Cloud Task with a scheduled delay in Google Cloud?
easy
A. Use Pub/Sub with a delay attribute
B. Use Cloud Tasks client and set scheduleTime to future timestamp
C. Send a message to Pub/Sub and rely on subscriber delay
D. Create a Cloud Function with a timer trigger instead

Solution

  1. Step 1: Identify scheduling method in Cloud Tasks

    Cloud Tasks allows setting a scheduleTime property to delay task execution until a future timestamp.
  2. Step 2: Eliminate incorrect options

    Pub/Sub does not support scheduling messages; Cloud Functions timer triggers are separate services.
  3. Final Answer:

    Use Cloud Tasks client and set scheduleTime to future timestamp -> Option B
  4. Quick Check:

    Scheduled tasks = Cloud Tasks scheduleTime [OK]
Hint: Schedule tasks with Cloud Tasks scheduleTime, not Pub/Sub [OK]
Common Mistakes:
  • Trying to delay Pub/Sub messages directly
  • Confusing Cloud Functions timers with Cloud Tasks scheduling
  • Assuming subscribers can delay message processing
3. Given the following scenario: A Cloud Task is created with maxAttempts set to 3 and a retry delay of 10 seconds. If the task fails twice, what happens next?
medium
A. The task is retried after 10 seconds delay for the third attempt
B. The task is retried immediately without delay
C. The task is discarded after the second failure
D. Pub/Sub resends the message automatically

Solution

  1. Step 1: Understand Cloud Tasks retry policy

    Cloud Tasks retries failed tasks up to maxAttempts, applying the configured retry delay between attempts.
  2. Step 2: Apply to given scenario

    After two failures, the third attempt will be retried after the 10 seconds delay before final failure or success.
  3. Final Answer:

    The task is retried after 10 seconds delay for the third attempt -> Option A
  4. Quick Check:

    Retries respect delay and maxAttempts in Cloud Tasks [OK]
Hint: Cloud Tasks retries wait delay before next try, up to maxAttempts [OK]
Common Mistakes:
  • Assuming immediate retry without delay
  • Thinking task is discarded too early
  • Confusing Pub/Sub automatic retries with Cloud Tasks
4. You have a Cloud Task that never executes and keeps retrying indefinitely. What is the most likely cause?
medium
A. The Cloud Task queue is paused
B. Pub/Sub subscription is missing
C. The task's maxAttempts is set to 0 or unlimited
D. The task's scheduleTime is in the past

Solution

  1. Step 1: Analyze retry behavior

    If a task retries indefinitely, it means it keeps failing but is still being retried.
  2. Step 2: Check queue state

    If the Cloud Task queue is paused, tasks will not execute but may keep retrying or remain pending.
  3. Step 3: Eliminate other options

    Pub/Sub subscription missing is unrelated to Cloud Tasks; maxAttempts 0 means no retries; scheduleTime in past triggers immediate execution.
  4. Final Answer:

    The Cloud Task queue is paused -> Option A
  5. Quick Check:

    Paused queue blocks task execution causing retries [OK]
Hint: Paused queue stops tasks but retries may appear stuck [OK]
Common Mistakes:
  • Confusing Pub/Sub with Cloud Tasks
  • Assuming maxAttempts 0 means infinite retries
  • Thinking scheduleTime in past delays execution
5. You need to design a system that processes user signup events by notifying multiple services quickly, but also schedules follow-up tasks with guaranteed retries and delays. Which combination of services should you use?
hard
A. Use only Cloud Tasks for both notifications and follow-ups
B. Use only Pub/Sub with delayed message delivery
C. Use Cloud Functions triggered by HTTP for all processing
D. Use Pub/Sub for notifications and Cloud Tasks for follow-up tasks

Solution

  1. Step 1: Identify service for quick multi-subscriber notifications

    Pub/Sub is ideal for sending events quickly to multiple subscribers asynchronously.
  2. Step 2: Identify service for scheduled, reliable task execution

    Cloud Tasks provides control over retries, delays, and guaranteed execution for follow-up work.
  3. Step 3: Combine services for best fit

    Use Pub/Sub to notify many services fast, and Cloud Tasks to manage follow-up tasks with retries and delays.
  4. Final Answer:

    Use Pub/Sub for notifications and Cloud Tasks for follow-up tasks -> Option D
  5. Quick Check:

    Pub/Sub for events + Cloud Tasks for reliable tasks [OK]
Hint: Combine Pub/Sub for events and Cloud Tasks for retries/delays [OK]
Common Mistakes:
  • Trying to use Pub/Sub for delayed retries
  • Using Cloud Tasks for broad event broadcasting
  • Ignoring retry guarantees needed for follow-ups
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard