Google CloudCloud Pub/SubMessaging

google_pubsub_topic cost estimation

A pub/sub topic for messaging. Priced per TB of message ingestion and delivery, with a generous free tier.

A google_pubsub_topic is a managed pub/sub topic for async messaging between services. Cloud Pub/Sub has a simple per-TB pricing model that's significantly different from AWS SNS/SQS or Azure Service Bus.

Pricing:

Message throughput: $40 per TiB of message data, applied to publish requests, delivery, and seek operations. The first 10 GB/month is free at the project level.

Cloud Pub/Sub Lite (a separate resource type) is cheaper per TiB but requires provisioning capacity (similar to Kinesis shards) and lacks some features. Right for very high-throughput workloads.

Snapshots and seek: snapshots are $0.27 per GB-month and seek operations count toward throughput. Right for replay scenarios.

Cross-region delivery: messages published in one region but consumed in another incur cross-region egress at standard GCP rates.

Storage: Pub/Sub stores undelivered messages for up to 7 days by default (configurable via message_retention_duration). Standard storage rates apply for messages held beyond the default.

There's no per-topic fee. Topics, subscriptions, and snapshots are all free as resources; you pay only for actual message throughput.

c3x estimates Pub/Sub from c3x-usage.yml's monthly_throughput_gb on the topic. Without that, the topic shows $0 with a note that cost is usage-based.

Terraform example

A minimal but realistic configuration that C3X can estimate.

resource "google_pubsub_topic" "events" {
  name = "production-events"

  message_retention_duration = "604800s"  # 7 days

  schema_settings {
    schema   = google_pubsub_schema.event.id
    encoding = "JSON"
  }
}

resource "google_pubsub_subscription" "processor" {
  name  = "event-processor"
  topic = google_pubsub_topic.events.name

  ack_deadline_seconds       = 60
  message_retention_duration = "604800s"

  retry_policy {
    minimum_backoff = "10s"
    maximum_backoff = "600s"
  }
}

Pricing dimensions

What you actually pay for when you provision google_pubsub_topic.

DimensionUnitWhat's being charged
Message throughputper TiBCounted across publish, delivery, and seek. First 10 GB/month free at project level.
$40/TiB
Snapshot storageper GB-monthStorage of message snapshots for replay.
$0.27/GB-month
Retained messages (beyond default)per GB-monthIf message_retention_duration is longer than default, retained but undelivered messages bill at standard storage rates.
Cross-region egressper GBMessages delivered to consumers in a different region.

Optimization tips

Common ways to reduce google_pubsub_topic cost without changing the workload.

Take advantage of the 10 GB/month free tier

Up to $0.40/month per project (small projects)

Most low-volume integrations and dev environments stay within free tier. The 10 GB is across the entire project, not per topic.

Use Pub/Sub Lite for very high-throughput workloads

Up to 80% on high-volume workloads

At sustained throughput above ~1 TiB/day, Lite is cheaper than standard Pub/Sub if you can manage provisioned capacity. Lite is a separate resource (google_pubsub_lite_topic).

Batch publishes and acknowledgments

Marginal — Pub/Sub bills by data, not request count

Publishing in batches reduces overhead. Subscription clients with high ack rates can use batched modify-ack-deadline calls to reduce request count.

Set short message_retention_duration

Storage for slow-consumer scenarios

Default is 7 days. If your consumers always process within 1 day, set retention to 24 hours. Undelivered messages cost storage; aged-out messages are deleted.

FAQ

Why does c3x show Pub/Sub topic as $0?

Pub/Sub topics themselves are free. Cost is entirely usage-based. Add monthly_throughput_gb to c3x-usage.yml on the topic to get a real estimate.

Is Pub/Sub cheaper than SNS/SQS?

Different model. SNS/SQS bill per million requests; Pub/Sub bills per TiB. For small messages at high frequency, SNS/SQS often wins. For larger messages at moderate frequency, Pub/Sub wins. Crossover depends on average message size.

What's the difference between Pub/Sub and Pub/Sub Lite?

Lite is a cheaper, regional-only, capacity-provisioned variant with fewer features (no schema registry, no exactly-once delivery, no filtering). Right for very high throughput in a single region.

Are subscriptions billed separately?

No, but message delivery to each subscription counts toward the topic's throughput. A message published once and delivered to 5 subscriptions counts as 6 TiB units (1 publish + 5 deliveries).

Related resources

Estimate this resource in your own Terraform

Free, open source, no API key. C3X parses your Terraform and shows line-item cost for every resource, including google_pubsub_topic.