Google Cloud Pub/Sub is a messaging service that lets applications send and receive messages asynchronously. It works like a postal system where publishers send messages to topics, and subscribers receive those messages independently.
Click to reveal answer
beginner
What is Google Cloud Tasks used for?
Google Cloud Tasks is a service to manage the execution, dispatch, and delivery of large numbers of distributed tasks. It helps schedule and control when and how tasks run, like a to-do list manager for background work.
Click to reveal answer
intermediate
How does Pub/Sub handle message delivery?
Pub/Sub delivers messages to subscribers asynchronously and supports at-least-once delivery. Subscribers can pull or receive messages pushed to them, and messages are retried until acknowledged.
Click to reveal answer
intermediate
What is a key difference in use cases between Pub/Sub and Cloud Tasks?
Pub/Sub is best for event-driven, real-time messaging between services. Cloud Tasks is better for managing asynchronous, reliable execution of background work with control over timing and retries.
Click to reveal answer
advanced
Can Cloud Tasks guarantee exactly-once execution of tasks?
Cloud Tasks aims for at-least-once execution but provides features like task deduplication and idempotency to help achieve effectively once-only processing.
Click to reveal answer
Which service is best suited for real-time event streaming between microservices?
AGoogle Cloud Pub/Sub
BGoogle Cloud Tasks
CGoogle Cloud Storage
DGoogle Compute Engine
✗ Incorrect
Pub/Sub is designed for real-time messaging and event streaming between services.
Which service allows scheduling and controlling the timing of background work?
AGoogle Cloud Pub/Sub
BGoogle Cloud Tasks
CGoogle BigQuery
DGoogle Cloud Functions
✗ Incorrect
Cloud Tasks manages execution timing and retries for background tasks.
How does Pub/Sub deliver messages to subscribers?
ASynchronously with guaranteed exactly-once delivery
BAsynchronously with at-least-once delivery
COnly once with no retries
DOnly on demand without retries
✗ Incorrect
Pub/Sub delivers messages asynchronously and retries until acknowledged, ensuring at-least-once delivery.
Which service is better for managing retries and failures of background jobs?
AGoogle Cloud Pub/Sub
BGoogle Cloud Tasks
CGoogle Cloud Storage
DGoogle Kubernetes Engine
✗ Incorrect
Cloud Tasks provides built-in retry policies and failure handling for background jobs.
Which statement about Cloud Tasks is true?
AIt is used for streaming large volumes of messages.
BIt guarantees exactly-once task execution without any developer effort.
CIt helps schedule and dispatch asynchronous tasks with retry control.
DIt is a database service for storing tasks.
✗ Incorrect
Cloud Tasks schedules and dispatches asynchronous tasks and allows control over retries.
Explain the main differences between Google Cloud Pub/Sub and Cloud Tasks.
Think about messaging vs task management roles.
You got /4 concepts.
Describe a scenario where you would choose Cloud Tasks over Pub/Sub.
Consider background job scheduling needs.
You got /4 concepts.
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
Step 1: Understand Pub/Sub's purpose
Pub/Sub is designed to send messages to many subscribers quickly and asynchronously, enabling event-driven architectures.
Step 2: Compare with Cloud Tasks
Cloud Tasks manages individual work items with control over retries and timing, not broad message delivery.
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
Step 1: Identify scheduling method in Cloud Tasks
Cloud Tasks allows setting a scheduleTime property to delay task execution until a future timestamp.
Step 2: Eliminate incorrect options
Pub/Sub does not support scheduling messages; Cloud Functions timer triggers are separate services.
Final Answer:
Use Cloud Tasks client and set scheduleTime to future timestamp -> Option B
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
Step 1: Understand Cloud Tasks retry policy
Cloud Tasks retries failed tasks up to maxAttempts, applying the configured retry delay between attempts.
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.
Final Answer:
The task is retried after 10 seconds delay for the third attempt -> Option A
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
Step 1: Analyze retry behavior
If a task retries indefinitely, it means it keeps failing but is still being retried.
Step 2: Check queue state
If the Cloud Task queue is paused, tasks will not execute but may keep retrying or remain pending.
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.
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
Step 1: Identify service for quick multi-subscriber notifications
Pub/Sub is ideal for sending events quickly to multiple subscribers asynchronously.
Step 2: Identify service for scheduled, reliable task execution
Cloud Tasks provides control over retries, delays, and guaranteed execution for follow-up work.
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.
Final Answer:
Use Pub/Sub for notifications and Cloud Tasks for follow-up tasks -> Option D
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 unknownstrongwhile earning +1 Grip toward your certificate.