You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Google Cloud Tasks is a fully managed service for executing, dispatching, and delivering tasks asynchronously. While Pub/Sub is designed for event-driven messaging between services, Cloud Tasks is designed for task execution — specifically, for situations where you need to control the rate, timing, and retry behaviour of work items sent to a target service.
Understanding when to use Cloud Tasks versus Pub/Sub is essential:
| Aspect | Cloud Tasks | Pub/Sub |
|---|---|---|
| Pattern | Task dispatch (command) | Publish-subscribe (event) |
| Consumers | One target per task | Many subscribers per topic |
| Rate control | Yes (configurable rate limits) | No (subscriber controls pace) |
| Scheduling | Yes (schedule tasks for future execution) | No (immediate delivery) |
| Deduplication | Yes (task names for deduplication) | Via exactly-once or client-side |
| Delivery | HTTP (App Engine or generic target) | Pull, push, BigQuery, GCS |
| Fan-out | No — one task, one handler | Yes — one message, many subscribers |
| Use case | "Do this later" | "This happened" |
A queue is a container for tasks. Each queue has its own configuration for rate limits, retry policies, and routing.
# Create a queue
gcloud tasks queues create order-processing-queue \
--location=europe-west1
# List queues
gcloud tasks queues list --location=europe-west1
A task is a unit of work to be dispatched to a target. Each task contains:
| Component | Description |
|---|---|
| Target | The HTTP endpoint to call |
| Method | HTTP method (GET, POST, PUT, DELETE) |
| Body | Request body (for POST/PUT) |
| Headers | Custom HTTP headers |
| Schedule time | When the task should be dispatched (optional) |
| Name | Unique task name for deduplication (optional) |
Cloud Tasks supports two target types:
| Target | Description | Authentication |
|---|---|---|
| HTTP target | Any publicly reachable HTTPS endpoint | OIDC or OAuth tokens |
| App Engine target | App Engine service within the same project | Automatic |
One of Cloud Tasks' most valuable features is rate limiting. You can control how fast tasks are dispatched to prevent overwhelming downstream services.
# Configure rate limits on a queue
gcloud tasks queues update order-processing-queue \
--location=europe-west1 \
--max-dispatches-per-second=100 \
--max-concurrent-dispatches=10
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.