Both Cloud Tasks and Pub/Sub may be used to implement message passing and asynchronous integration, but while they function in similar ways, they are not identical. This page helps you choose the right product for your use case.
The core difference between Pub/Sub and Cloud Tasks is the notion of implicit vs explicit invocation.
Pub/Sub aims to decouple publishers of events and subscribers to those events. Publishers do not need to know anything about their subscribers. As a result, Pub/Sub gives publishers no control over the delivery of the messages save for the guarantee of delivery. In this way, Pub/Sub supports implicit invocation: a publisher implicitly causes the subscribers to execute by publishing an event.
By contrast, Cloud Tasks is aimed at explicit invocation where the publisher retains full control of execution. In particular, a publisher specifies an endpoint where each message is to be delivered.
In addition, Cloud Tasks provides tools for queue and task management unavailable to Pub/Sub publishers, including:
- Scheduling specific delivery times
- Delivery rate controls
- Configurable retries
- Access and management of individual tasks in a queue
- Task/message creation deduplication
Detailed feature comparison
|Feature||Cloud Tasks||Cloud Pub/Sub|
|Push via webhooks||Yes||Yes|
|At least once delivery guarantee||Yes||Yes|
|Task creation deduplication||Yes||No|
|Ordered delivery||No. Enqueued task order is preserved on best-effort basis.||Yes with ordering keys|
|Explicit rate controls||Yes||Pull subscriber clients can implement flow control|
|Pull via API||No||Yes|
|Multiple handlers/subscribers per message||No||Yes|
|Task/message retention||30 days||Up to 31 days|
|Max size of task/message||1MB||10MB|
|Max delivery rate||500 qps/queue||No upper limit|
|Maximum push handler/subscriber processing duration||30 minutes (HTTP)
10 minutes (App Engine Standard automatic scaling)
24 hours (App Engine Standard manual or basic scaling)
60 minutes (App Engine Flexible)
|10 minutes for push operations|
|Number of queues/subscriptions per project||1,000/project, more available via quota increase request||10,000/project|