Cloud Pub/Sub pricing is based on:
- Message ingestion and delivery
- Seek-related message storage: snapshots and retained acknowledged messages
Message ingestion and delivery
Data volume is computed from message and attribute data for pull, push, and publish operations. Message ingestion and delivery are priced according to the data volume transmitted in a calendar month:
|Monthly data volume||Price Per TiB|
Example: message ingestion and delivery
To illustrate the overall costs of operation you might expect, consider an application that
publishes 1024 KB messages to a topic with two subscriptions, at a rate of 1 MiB/second.
Assuming that the subscribers are keeping up, Cloud Pub/Sub is ingesting 1 MiB/second and
delivering 2 MiB/second, for a total data transmission rate of 3 MiB/second. Over the course of
a 30-day month, this amounts to
3 MiB/second x 3600 seconds/hour x 24 hours/day x 30 days/month
x 1 month/(2^20 MiB/TiB) = 7.416 TiB. After subtracting the free tier (10 GB), the
data volume is 7.406 TiB in the $60/TiB tier and the charge is $444.36.
Minimum billable volume
The minimum billable volume of data per request (not message) is 1 KB of data. For example, 100
publish requests, each containing one 500-byte message, have an actual data
volume of 50 KB but a billable data volume of
1 KB/request x 100 requests = 100 KB.
However, if all 100 messages are published in a single Publish request, the billable data volume is
equal to the actual one (50 KB).
If you are using Cloud Pub/Sub across projects, Cloud Pub/Sub fees are billed to the project that contains the requested resource (e.g., subscription). For example, a service account in project A might be given subscriber access to a subscription in Project B (that is under billing account B). Billing account B will be billed for the data that is pulled from the subscription by service account A. Alternatively, if the subscription resides in project A (even if it is attached to a topic in project B), account A will be billed for data that is pulled from the subscription.
Seek-related message storage
Message storage fees, at a rate of $0.27/GiB-month, are charged in these cases:
- A subscription is configured to retain acknowledged messages to make it possible to re-process them using seek. In this case, storage fees are charged for retained acknowledged messages.
- A snapshot of a subscription is created. In this case, message storage fees are charged for storing all of the snapshot’s unacknowledged messages.
Example: subscription with retained acknowledged messages
Consider the message ingestion example, except with a single subscription that is configured to retain acknowledged messages:
- The subscription’s topic has a steady 1MiB/second rate of incoming data.
- The subscriber is keeping up with the data on the subscription, consuming it at 1 MiB/second and has negligible new message backlog.
- The subscription is configured to retain acknowledged messages for 7 days.
- The acknowledged message volume grows by
1MiB/second x 3600 seconds/hour x 24 hours/day = 86.4 GiB/day.
- After 7 days, retained acknowledged messages start expiring and the total volume of stored
acknowledged messages plateaus at
7 days x 86.4 GiB/day = 605GiB.
605 GiB-month x $0.27/GiB-month = $163.
Example: snapshot message storage fees
Snapshot message storage fees consist of an incremental charge for new messages published to
the snapshot’s topic and a one-time fee at the time of creation. Consider a snapshot of the
subscription with retained acknowledged messages. The snapshot will have a lifetime of seven days
unless it is deleted earlier, since the subscription from which it is created has no backlog of unacknowledged
messages. The data published in the first minute (60 MiB) will be stored for 7 days - 1 minute, the
data published in the second minute for 7 days - 2 minutes, and so forth. This results in a backlog
size of 605 GiB when the snapshot expires, amounting to
1/2 x 605 GiB x 7 days = 2118 GiB-days of
storage used, for which the charge is
2118 GiB-days x (1/30 months/day) x $0.27/GiB-month =
$19 in a 30-day month. Thus, snapshots are potentially cheaper than acknowledged message
Example: snapshot of a subscription with a backlog
If the subscription has a backlog of unacknowledged messages when the snapshot is
created, a one-time fee equivalent to storing that backlog for the full seven days is charged. For example,
consider a subscription with a 10 GiB unacknowledged message backlog. The one-time fee at the time
of snapshot creation would be
10 GiB x 7 days / 30 days/month x 0.27/GiB-month =