This page provides details to help you choose between Pub/Sub and Pub/Sub Lite. Pub/Sub and Pub/Sub Lite are asynchronous messaging services. For more information about publish-subscribe messaging, see the Pub/Sub overview.
Pub/Sub is a fully managed, high availability service that replicates messages across multiple zones. Pub/Sub is for most use cases.
To minimize cost for systems with predictable traffic patterns, you can use Pub/Sub Lite. If you publish 1 MiB-1 GiB of messages per second, Pub/Sub Lite might be an order of magnitude cheaper. For example, if you published and received 2.5 TiB/mo of data and stored messages for 24 hours (84 GiB/mo of storage capacity), Pub/Sub Lite cost would be $30/mo compared to $200/mo with Pub/Sub. That is a savings of 85%. To achieve these savings, Pub/Sub Lite uses zonal storage and pre-provisioned capacity.
For more information about the cost difference between Pub/Sub and Pub/Sub Lite, see the Pub/Sub Lite pricing.
The following table compares the key differences between Pub/Sub and Pub/Sub Lite:
|Message replication||Multi-zone in single region||Single zone|
|Capacity||Automatically provisioned||Provision before you use|
|Pricing||Pay for the capacity that you use||Pay for the capacity that you provision|
|Storage||Unlimited||30 GiB-10 TiB per Lite topic|
|Retention period||Up to 7 days||Unlimited|
|Service endpoints||Global and regional||Regional|
In a Pub/Sub system, publisher applications send messages to topics, and subscriber applications receive messages from subscriptions. Topics and subscriptions are global resources, so they can be in different Cloud projects.
If a topic and subscription are in different projects, different quotas apply, and publishers and subscribers are billed independently. For details, see the Pub/Sub pricing.
Pub/Sub scales automatically. Any number of publishers and subscribers can send and receive any number of messages. The Pub/Sub service can store messages in any region.
Subscribers can request messages from Pub/Sub, or Pub/Sub can initiate requests. The following Google Cloud products can automatically authenticate requests from Pub/Sub:
- App Engine
- Cloud Functions
- Cloud Run
To read or write messages in Apache Beam pipelines, you can use Dataflow streaming templates or the Pub/Sub I/O for the Apache Beam SDK. The Pub/Sub I/O is available in the Apache Beam SDK for Java and the Apache Beam SDK for Python.
In a Pub/Sub Lite system, publishers send messages to Lite topics and subscribers receive messages from Lite subscriptions. Lite topics and Lite subscriptions are zonal resources that must be in the same Cloud project and zone. For a list of zones that Pub/Sub Lite supports, see Pub/Sub Lite locations.
If you run a publisher or subscriber on Google Cloud, the application can run in a different Cloud project from the Cloud project that the Lite topic and Lite subscription are in.
Lite topics consist of partitions; a partition is a log of messages. Publishers assign each message to a partition, and the Pub/Sub Lite service appends each message to the log. The Pub/Sub Lite service delivers the messages from a partition in order.
Subscribers must request messages from Pub/Sub Lite. To request messages, subscribers establish bidirectional streaming connections with each of the partitions.
You manually provision the capacity to publish messages to Lite topics, receive messages from Lite topics, and store messages in Lite topics. When you create a Lite topic, you specify the number of partitions and the storage per partition. To increase the capacity of a Lite topic, you can scale the capacity of the partitions.
To read or write messages in Apache Beam pipelines, you can use the Pub/Sub Lite I/O with the Apache Beam SDK for Java.