This document explains how to use and manage Pub/Sub Lite reservations. This document also explains the concept of capacity units and how to determine how many you require to accommodate the throughput of your application.
Overview of Lite reservations
Lite reservations provision and dynamically share throughput capacity among one or multiple Lite topics in a region. These topics may be regional or zonal Lite topics. Using Lite reservations is a better option than setting the throughput capacity of individual Lite topics. With Lite reservations, you manage and monitor fewer resources. Also, you don't have to choose the throughput capacity of individual Lite topics.
To use a Lite reservation, you attach a Lite topic that is in the same region to the specific Lite reservation. You can attach a single Lite reservation to both zonal and regional Lite topics. All the partitions in a Lite topic that is attached to a Lite reservation dynamically consume from the throughput capacity provisioned in the Lite reservation. If you do specify a Lite reservation for a Lite topic, you can also include rate limits to limit the throughput capacity of each partition of the Lite topic.
Overview of capacity units
The throughput capacity of a Lite reservation is provisioned in capacity units.
One capacity unit corresponds to the following throughput:
Lite topic type | Publish throughput in MiBps | Subscribe throughput in MiBps |
---|---|---|
Zonal | 1 | 2 |
Regional | 0.25 | 0.5 |
Guidelines to name a reservation
A Pub/Sub Lite resource name uniquely identifies a Pub/Sub Lite resource, such as a topic, subscription, or reservation. The resource name must fit the following format:
projects/project-identifier/collection/ID
project-identifier
: Must be the project ID or project number, available from the Google Cloud console. For example,my-cool-project
is a project ID.123456789123
is a project number.collection
: Must be one oftopics
,subscriptions
, orreservations
.ID
: Must conform to the following guidelines:- Not begin with the string
goog
- Start with a letter
- Contain between 3 and 255 characters
- Contain only the following characters: Letters
[A-Za-z]
, numbers[0-9]
, dashes-
, underscores_
, periods.
, tildes~
, plus signs+
, and percent signs%
You can use the special characters in the preceding list in resource names without URL-encoding. However, you must ensure that any other special characters are properly encoded or decoded when you use them in URLs. For example,
mi-tópico
is an invalid ID. However,mi-t%C3%B3pico
is valid. This format is important when you make REST calls.- Not begin with the string
Guidelines for using a Lite reservation
Provisioning throughput with Lite reservations is required for regional Lite topics and is optional for zonal Lite topics. A Lite reservation is a regional resource.
Keep the following in mind when you are planning to configure a Lite reservation:
The number of capacity units needed for a Lite reservation must equal the peak throughput you expect in any given minute across all topics and subscriptions in that Lite reservation.
When the combined throughput of all the Lite topics in a Lite reservation reaches its capacity, publishing and delivery are throttled. The Pub/Sub Lite servers stop sending messages to the clients, and messages get buffered in the publisher client. You can set up an alert for
reservation/throughput_capacity/utilization
to let you know when the reservation is in danger of being throttled so that you can increase the reservation size.You can update the throughput of the reservations as often as you like. Changes take effect in under a minute. However, if you decrease a reservation's throughput, you are continued to be charged for the higher amount for a 24-hour period. Pub/Sub Lite is inherently a pay-for-capacity system, where scale-ups are instantaneous and scale-downs are possible.
All Lite topics attached to a Lite reservation consume from the same pool of throughput capacity. It's therefore possible for a Lite topic to suddenly use a large amount of throughput capacity, starving other Lite topics and preventing them from publishing or receiving messages. If you require complete isolation across Lite topics, you can attach them to independent reservations.
Impact of partitions on a Lite reservation
The total number of partitions across all Lite topics in a Lite reservation must be not greater than the number of capacity units reserved. For example, you cannot attach a Lite reservation of 10 capacity units to a Lite topic or a set of Lite topics whose total number of partitions is greater than 10.
Calculate capacity units for a Lite reservation
The size of a Lite reservation is defined by the number of capacity units. The following examples illustrate how to estimate the capacity required for individual Lite topics.
Determine the peak publish throughput.
Estimate the peak in the throughput of all the Lite topics attached to the Lite reservation. A rough estimate for the throughput is sufficient since you can always update the size of the reservation.
Determine the peak subscribe throughput.
The peak subscribe throughput is computed similarly to the peak publish throughput. However, consider that your subscribers don't necessarily need to receive messages at the peak rate of the publishers. If delays in processing are acceptable, Pub/Sub Lite allows you to buffer messages and process them at a steady rate. At the same time, you may want to have more subscribe capacity than publish capacity to accommodate the occasional downtime of subscribers.
Determine the total number of capacity units required.
The table in the preceding section specifies the number of MiBps that a capacity unit can accommodate for different operations. The following is the formula to calculate the capacity units required for a sample Lite reservation:
- Peak publish throughput of the zonal Lite topics =
Pz MiBps
- Peak publish throughput of the regional Lite topics =
Pr MiBps
- Peak subscribe throughput of the zonal Lite topics =
Sz MiBps
Peak subscribe throughput of the regional Lite topics =
Sr MiBps
Number of capacity units required =
(Pz / 1 MiBps) + (Pr/0.25 MiBps) + (Sz/2 MiBps) + (Sr/0.5 MiBps)
If the number is not whole, you must round up the value.
- Peak publish throughput of the zonal Lite topics =
Configure throughput capacity without a Lite reservation
Topic publish throughput capacity: You can specify 4 to 16 MiBps of throughput capacity, and the value must be an integer.
Topic subscribe throughput capacity: You can specify 4 to 32 MiBps of throughput capacity, and the value must be an integer.
For subscribe throughput, we recommend that you provision your throughput capacity to equal the product of your expected publish throughput and the number of subscriptions on your topic.
Publisher and subscriber capacity provisioned for an individual topic are not interchangeable. For this reason, we recommend always using reservations.
There are differences in billing when provisioning capacity directly for topics instead of using reservations. See the Pub/Sub Lite pricing page for details.
Create a Lite reservation
A Lite reservation must be in the same project and region as any Lite topics that are attached to it. For a list of the available zones and regions, see Pub/Sub Lite locations.
You can create a Lite reservation with the Google Cloud console, the Google Cloud CLI, or the Pub/Sub Lite API.
Console
Go to the Lite Reservations page.
Click Create Lite reservation.
Select a region.
Enter a Lite reservation ID.
Provision the amount of throughput capacity units.
Click Create.
gcloud
To create a Lite reservation, use the
gcloud pubsub lite-reservations create
command:
gcloud pubsub lite-reservations create myRes \ --location=us-central1 \ --throughput-capacity=INTEGER_NUMBER_OF_UNITS
gcloud pubsub lite-topics create myTopic \ --throughput-reservation=myRez \ --zone=ZONE \ --location=us-central1a \ --partitions \ --storage
Go
Before running this sample, follow the Go setup instructions in Pub/Sub Lite Client Libraries.
Java
Before running this sample, follow the Java setup instructions in Pub/Sub Lite Client Libraries.
Python
Before running this sample, follow the Python setup instructions in Pub/Sub Lite Client Libraries.
Update a Lite reservation
You can update the number of capacity units configured for a Lite reservation.
You can update a Lite reservation with the Google Cloud console, the Google Cloud CLI, or the Pub/Sub Lite API.
Console
Go to the Lite Reservations page.
Click the Lite reservation ID.
In the Lite reservation details page, click Edit.
gcloud
To update a Lite reservation, use the
gcloud pubsub lite-reservations update
command:
gcloud pubsub lite-reservations update RESERVATION_ID \ --location=REGION \ --throughput-capacity=THROUGHPUT_CAPACITY
Replace the following:
- RESERVATION_ID: the ID of the Lite reservation
- REGION: the region of the reservation
- THROUGHPUT_CAPACITY: The reservation throughput capacity.
Go
Before running this sample, follow the Go setup instructions in Pub/Sub Lite Client Libraries.
Java
Before running this sample, follow the Java setup instructions in Pub/Sub Lite Client Libraries.
Python
Before running this sample, follow the Python setup instructions in Pub/Sub Lite Client Libraries.
Get Lite reservation details
You can get details about a Lite reservation using the Google Cloud console, the Google Cloud CLI, or the Pub/Sub Lite API.
Console
Go to the Lite Reservations page.
Click the Lite reservation ID.
gcloud
To get details about a Lite reservation, use the
gcloud pubsub lite-reservations describe
command:
gcloud pubsub lite-reservations describe RESERVATION_ID \ --location=REGION
Replace the following:
- RESERVATION_ID: the ID of the Lite reservation
- REGION: the region of the reservation
Go
Before running this sample, follow the Go setup instructions in Pub/Sub Lite Client Libraries.
Java
Before running this sample, follow the Java setup instructions in Pub/Sub Lite Client Libraries.
Python
Before running this sample, follow the Python setup instructions in Pub/Sub Lite Client Libraries.
List Lite reservations
Console
Go to the Lite Reservations page.
gcloud
To view a list of the Lite reservations in a project, use the
gcloud pubsub lite-reservations list
command:
gcloud pubsub lite-reservations list \ --location=REGION
Replace the following:
- REGION: the region of the reservation
Go
Before running this sample, follow the Go setup instructions in Pub/Sub Lite Client Libraries.
Java
Before running this sample, follow the Java setup instructions in Pub/Sub Lite Client Libraries.
Python
Before running this sample, follow the Python setup instructions in Pub/Sub Lite Client Libraries.
Delete a Lite reservation
You can delete Lite reservations with the Google Cloud console, the Google Cloud CLI, or the Pub/Sub Lite API. In order to delete a reservation, it must not contain any topics. You can attach existing topics to a different reservation, then delete the reservation.
Console
Go to the Lite Reservations page.
Click the Lite reservation ID.
In the Lite reservation details page, click Delete.
In the dialog that appears, click Delete to confirm that you want to delete the Lite reservation.
gcloud
To delete a Lite reservation, use the
gcloud pubsub lite-reservations delete
command:
gcloud pubsub lite-reservations delete RESERVATION_ID \ --location=REGION
Replace the following:
- RESERVATION_ID: the ID of the Lite reservation
- REGION: the region of the reservation
Go
Before running this sample, follow the Go setup instructions in Pub/Sub Lite Client Libraries.
Java
Before running this sample, follow the Java setup instructions in Pub/Sub Lite Client Libraries.
Python
Before running this sample, follow the Python setup instructions in Pub/Sub Lite Client Libraries.
What's next
- Learn about Pub/Sub Lite pricing.
- Create a Lite topic.