# Cloud Tasks or Pub/Sub: explicit delivery or broadcast

> Cloud Tasks when the sender must name the handler and set its pace, deadline and time; Pub/Sub when it should not know who listens. Where Cloud Scheduler fits, and the quiet failure each choice hides.

- Canonical: https://www.alpacamango.com/docs/cloud-tasks-or-pub-sub
- Author: Captain Spitt McGee
- Published: 2026-11-22 · Updated: 2026-11-22
- Topics: Google Cloud, Event-driven, Architecture

**Use Cloud Tasks when the sender knows which endpoint must do the work and has to decide how fast, how often and by when it runs. Use Pub/Sub when the sender should announce that something happened and not know who acts on it. Cloud Scheduler is neither: it is the clock that starts either one. Each choice hides a different failure, and the design is unfinished until that failure lands where someone will see it.**

## Who knows about the work

Google calls the difference explicit against implicit invocation, and means it literally. A Cloud Tasks task carries its own destination: a URL on Cloud Run, GKE, Compute Engine or your own server, and, when the target needs it, the service account that signs the request. One task reaches one handler. A Pub/Sub message carries no destination. Every subscription on the topic gets its own copy, and the publisher cannot tell whether there are three subscriptions or none.

That one property decides what the sender controls. A queue sets the receiver's pace: up to 500 dispatches a second and 5,000 in flight, or as little as a fragile downstream can take. A task can wait until a chosen time up to 30 days ahead, gets up to 30 minutes to answer where a push subscriber gets 10, and can carry a name, so a second create with that name fails instead of queueing a duplicate. Pub/Sub push has none of these: it widens its concurrent pushes while your endpoint acknowledges and backs off when it does not. That suits a service you own and scale, not a partner API with a fixed rate limit.

```bash
gcloud tasks queues create invoice-mail --location=europe-west2 \
  --max-dispatches-per-second=5 --max-attempts=8 --max-retry-duration=0s \
  --log-sampling-ratio=1.0
gcloud tasks create-http-task "$TASK_ID" --queue=invoice-mail \
  --location=europe-west2 --url="$MAILER_URL/send" \
  --schedule-time="2026-12-17T09:00:00Z" --oidc-service-account-email="$TASKS_SA"
```

Some limits point the other way: a task holds at most 1 MiB against a message's 10 MB, a queue is regional while a topic is global, and a queue keeps order only on a best-effort basis where Pub/Sub guarantees it per ordering key (see [ordering and exactly-once delivery](/docs/pub-sub-ordering-and-exactly-once)). The two also compose: publish the order event, and let the one subscriber that calls the rate-limited partner turn it into a task.

## Where Cloud Scheduler fits

Cloud Scheduler sends a job on a cron schedule to an HTTP endpoint, a Pub/Sub topic or App Engine. Its time belongs to the clock; a task's schedule time belongs to one piece of data. "Every night at two" is a Scheduler job. "Remind this customer three days after the invoice" is a task, created with the invoice.

The two combine when a nightly job must touch every tenant: Scheduler calls a small handler that creates one named task per tenant in a rate-capped queue. Scheduler delivers at least once, so the handler may run twice in a night. Name each task with a hash of the tenant and the date, and the second run's creates fail as duplicates while the first run's tasks are queued and for up to 24 hours after. Named tasks are slower to create, and Google asks for hashed, not sequential, names. If several services should react to one tick and none needs pacing, point Scheduler at a topic.

## The failure each choice hides

**Pub/Sub hides the missing reader.** A successful publish means Pub/Sub accepted the message, never that anyone was listening. A subscription receives only what is published after it exists, so an event sent before a new consumer subscribes reaches nobody, and nothing errors. A subscription on a quiet topic expires after 31 days without activity unless told otherwise. Without a dead-letter topic, a message the subscriber keeps rejecting is retried until retention runs out, seven days by default, and can then be discarded.

```bash
gcloud pubsub subscriptions create billing-orders --topic=order-events \
  --push-endpoint="$BILLING_URL/events" --push-auth-service-account="$PUSH_SA" \
  --dead-letter-topic=order-events-dead --max-delivery-attempts=10 \
  --expiration-period=never
```

Alert on each subscription's oldest unacknowledged message, not on the topic. [Idempotent consumers and dead-letter topics](/docs/pub-sub-idempotent-consumers-dead-letter) builds the consumer half.

**Cloud Tasks hides the work that never ran.** The sender chose the target, so it owns the outcome, and there is no dead-letter queue: a task that has used up its retries is deleted. A queue logs nothing by default (its log sampling ratio starts at zero), so that deletion can leave no trace; the last flag on the queue above fixes it. With attempts capped and the retry duration unlimited, the handler can spot its final try from the `X-CloudTasks-TaskRetryCount` header and store the payload before failing. A rate cap hides a second failure: a surge does not fail, it waits. Watch queue depth: a task undelivered after 31 days is deleted too.

## On AWS and Azure

Neither has a single Cloud Tasks. On AWS the nearest build is an SQS queue drained by Lambda, with maximum concurrency on the event source mapping capping concurrency rather than rate, and EventBridge Scheduler for one-time invocations and cron; broadcast is SNS or EventBridge. On Azure, a Service Bus queue offers scheduled messages, duplicate detection (Standard and Premium tiers) and the dead-letter subqueue Cloud Tasks lacks; broadcast is a Service Bus topic or Event Grid, and the clock a timer-triggered function. [Event-driven architecture on Google Cloud](/docs/event-driven-architecture-on-google-cloud) places both among Google's other patterns.

## The diagram

A nightly Scheduler job starts an order service with two outlets: a named task through a rate-capped queue to the one mailer, and an event copied to three subscribers. [Open it in archhy](https://archhy.com/d/a3olIdyXOgj4?utm_source=alpacamango) and press Make a copy to adapt it.

Reference documentation: [Choose Cloud Tasks or Pub/Sub](https://docs.cloud.google.com/tasks/docs/comp-pub-sub), [About Cloud Scheduler](https://docs.cloud.google.com/scheduler/docs/overview), [Cloud Tasks limits](https://docs.cloud.google.com/tasks/docs/quotas), [dead-letter topics](https://docs.cloud.google.com/pubsub/docs/dead-letter-topics).
