Cloud Pub/Sub pricing is based on:
- Message ingestion and delivery
- Seek-related message storage: snapshots and retained acknowledged messages
Message ingestion and delivery
Pricing schedule until June 21, 2019
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|
|First 10 GB||$0.00|
|Next 50 TiB||$60|
|Next 100 TiB||$50|
|Beyond 150 TiB||$40|
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 example 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 per 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 (such as a 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 is 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 is billed for data that is pulled from the subscription.
Message delivery pricing starting in June 2019
The price for publishing or delivery of messages is $40 per TiB, with no tiers. In addition,
we are introducing fees for region egress of data. The fees for internet egress and
message delivery between GCP regions will be consistent with the
Compute Engine network rates,
except for zone egress and egress to Google
products. There are no zone egress fees for Cloud Pub/Sub usage. Egress
to Google products is not exempt from egress fees. For example,
a 1MiB message published in
us-west1 and delivered to a subscriber in
results in charges totaling 3MiB between two distinct SKUs: 2 MiB of Message Delivery Basic
(1 MiB of publish and the delivery) and 1MiB of Inter-Region Data Delivery from Americas
To prepare for this change, you can analyze your own usage using Billing Export to BigQuery. Once you set up the export for your billing account, you can use a query like this one to understand your usage:
SELECT TIMESTAMP_TRUNC(usage_start_time, day) as usage_date, sku.description, usage.unit, sum(usage.amount) as egress_volume FROM `BILLING_EXPORT_TABLE` WHERE _PARTITIONTIME >= TIMESTAMP("2019-01-01") AND service.description = "Cloud Pub/Sub" AND (sku.description like "Internet data%" OR sku.description like "Inter-region data%") GROUP BY usage_date, sku.description, usage.unit;
Seek-related message storage
Message storage fees, at a rate of $0.27 per 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 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 has 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) is stored for 7 days - 1 minute, the
data published in the second minute for 7 days - 2 minutes, and so forth. This scenario 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 a potentially cost-effective
alternative to acknowledged message retention.
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 =
Resource location restriction implications
A message storage policy can result in additional region egress (network) fees if the policy forces the data to exit a GCP region. Consider a message that is:
- Published in region A
- Routed to region B for storage
- Delivered to a subscriber client in region C
In this case:
- The project that contains the topic is billed for network egress from region A to region B.
- The project that contains the subscription is billed for egress from region B to region C.
The project that contains the topic will be charged an egress fee only if the published message is stored in a region different from the region where the message was published (that is, B is actually a different region from A). The project that contains the subscription will be charged an egress fee only if the published message is stored in a region different from where the subscriber client is (C is not the same as B).